Str1=Usc_Search.Name;
Usc_Search 这个我的用户控件ID,
Name 这是我的控件里定义的string类型属性,
可为什么提示: c:\inetpub\wwwroot\MyWebsite1\SearchPage.aspx.cs(37): 非静态的字段、方法或属性“MyWebsite1.Usc_Search.Name”要求对象引用 ?

解决方案 »

  1.   

    Name必须是static才能这样调用:Str1=Usc_Search.Name
    (protected static string Name;)
      

  2.   

    public static String Name 
    {
    get
    {
    return Key.Text;
    }
    set
    {

    Key.Text = Server.HtmlEncode(value);
    }
    }
    提示 如下:
    c:\inetpub\wwwroot\MyWebsite1\Usc_Search_wide.ascx.cs(20): 类型或命名空间名称“Server”在类或命名空间“System.Web.UI.UserControl”中不存在(是否缺少程序集引用?)