我在母版页里面有一个控件lable1,主要是显示统计登录次数 
要在后台上写一句 
Label1.Text = string.Format("当前在线:{0}人", Application["counter"]); 
但是在其它页面引用母版页的时候总是提示当前页不存在lable1 
有人帮我回答一下吗
谢谢

解决方案 »

  1.   


    if(this.Master != null)
    {
        Label lab = this.Master.FindControl("Label1");
        if(lab != null)
        {
            lab.Text = string.Format("当前在线:{0}人", Application["counter"]); 
        }
    }
      

  2.   

    当前页当然不存在lable1啦,那个是母版的啊!看楼上的吧 
      

  3.   

    Label lab = this.Master.FindControl("Label1") as Label;漏了这个
      

  4.   

    感觉要做个传值吧,label1不是全局变量阿,只是母板的一个变量而已
      

  5.   

    当前页当然不存在lable1啦,那个是母版的啊
    二个都不在一个页面当然找不到了.
    用Master.FindControl()来试试.