各位大牛,今天遇到个问题,很头痛。
先看代码:
b.ascx
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <uc1:b ID="b1" runat="server">
        <SearchingItemsssss></SearchingItemsssss>
        </uc1:b>
    </div>
    </form>
</body>
</html>b.ascx.csnamespace WebApplication3
{
    public partial class b : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {        }        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
        NotifyParentProperty(true), MergableProperty(false), DefaultValue((string)null),
        Editor(@"System.Web.UI.Design.WebControls.ListItemsCollectionEditor,
        System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
        typeof(UITypeEditor)),
        PersistenceMode(PersistenceMode.InnerProperty)]
        public ListItemCollection SearchingItemsssss
        {
            set
            {
            }
            get
            {
                return new ListItemCollection();
            }
        }    }
}
default.aspx<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication3._Default" %><%@ Register Src="b.ascx" TagName="b" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <uc1:b ID="b1" runat="server">
            <SearchingItemsssss>
            </SearchingItemsssss>
        </uc1:b>
    </div>
    </form>
</body>
</html>无其余代码
但default.aspx页面在从“源”切换到“拆分”或“设计”时,就会提示“类型“System.Web.UI.UserControl”不具有名为“SearchingItemsssss”的公共属性” 
请问改如何弄啊,很急啊。

解决方案 »

  1.   

    这个只是为了重现错误的demo,目的很简单,就是在VS的“设计”和“拆分”窗口不要出现”创建控件时出错”这些信息。
      

  2.   

    TemplateContainer(typeof(TemplateControl) 在 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content),
      NotifyParentProperty(true), MergableProperty(false), DefaultValue((string)null),
      Editor(@"System.Web.UI.Design.WebControls.ListItemsCollectionEditor,
      System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a",
      typeof(UITypeEditor)),
      PersistenceMode(PersistenceMode.InnerProperty)] 加上 试试