在控件.cs声明控件属性        private int _RoomID = 0;        public int RoomID
        {
            get { return _RoomID; }
            set { _RoomID= value; }
        }
 在aspx页面<uc1:TC ID="TID" runat="server" RoomID="100" />这样便可以给想要传参数的控件传参数传值以上代码是我在网上找到的 但是我在ascx页面上怎么才能访问RoomID这个变量啊
直接用Label1.Text = "RoomID=" + RoomID; 组件在aspx里只显示RoomID= 

解决方案 »

  1.   

    Label1.Text = "RoomID=" + RoomID.ToString();
      

  2.   

    Label1.Text = "RoomID=" + RoomID.ToString();  出现以下错误用户代码未处理 System.NullReferenceException
      Message="未将对象引用设置到对象的实例。"
      Source="App_Web_readinfo.ascx.c95a9aa.pepiviqr"
      StackTrace:
           在 ascx_readInfo.Page_Load(Object sender, EventArgs e) 位置 i:\gangtie114\ascx\readInfo.ascx.cs:行号 68
           在 System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
           在 System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
           在 System.Web.UI.Control.OnLoad(EventArgs e)
           在 System.Web.UI.Control.LoadRecursive()
           在 System.Web.UI.Control.LoadRecursive()
           在 System.Web.UI.Control.LoadRecursive()
           在 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
      

  3.   

    将这个控件加到这个ascx文件里,然后在ASCX文件的CS里
    ((控件)FindControl("控件1")).RoomID
      

  4.   

    设置断点之后 看到 set get 都执行了 但是 RoomID为空值 所以出现问题