Accessing Master page control in ascx file

后端 未结 4 1718
我寻月下人不归
我寻月下人不归 2021-01-15 03:03

I have a master page file that contains a 2 menu\'s in a 2 panel controls. I also use a control to check if user is logged in and get the type of user.

Deppending on

4条回答
  •  鱼传尺愫
    2021-01-15 03:42

    Because the Panel control is inside a ContentPlaceHolder control, you must first get a reference to the ContentPlaceHolder and then use its FindControl method to locate the TextBox control.

    ContentPlaceHolder mpContentPlaceHolder;
    Panel pn;
    mpContentPlaceHolder = (ContentPlaceHolder)Master.FindControl("PHMainBlock");
    if(mpContentPlaceHolder != null)
    {
        pn = (Panel) mpContentPlaceHolder.FindControl("NormalUser");
        pn.Visible = false;
    }
    

    http://msdn.microsoft.com/en-us/library/xxwa0ff0.aspx

提交回复
热议问题