Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Accessing Master Page controls from Content Page user control

    So here's the current problem.

    I've got a Master Page, HelpSiteMaster.master,
    and I've got a Content Page, infoFlowContent.aspx.

    HelpSiteMaster.master contains many controls, and for example I'll use
    <asp:Literal ID="PopupVis" Text="hidden" runat="server"></asp:Literal>,
    which manipulates part of my stylesheet.

    Now, to access those controls from the code for infoFlowContent.aspx,
    found in infoFlowContent.aspx.cs, in my Master Page code I have:

    Code:
    public string PopupVisText
        {
            set
            {
                PopupVis.Text = value;
            }
        }
    which exposes the controls, and in the infoFlowContent code I use something like

    Code:
    Master.PopupVisText = "hidden";
    to access them.

    Now, that all works nicely, but now I have a user control CacheControl.ascx
    used in infoFlowContent.aspx, and I need to access the same Master Page
    controls in the code associated with this user control, found in CacheControl.ascx.cs.

    I tried

    Code:
    Page.Master.PopupVisText = "hidden";
    but this keeps giving me
    Code:
    CS0117: 'System.Web.UI.MasterPage' does not contain a definition for 'PopupVisText'
    Looked around online for awhile and couldn't find anything useful, so any help would be much appreciated.

  • #2
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by lbeckman View Post
    So here's the current problem.

    I've got a Master Page, HelpSiteMaster.master,
    and I've got a Content Page, infoFlowContent.aspx.

    HelpSiteMaster.master contains many controls, and for example I'll use
    <asp:Literal ID="PopupVis" Text="hidden" runat="server"></asp:Literal>,
    which manipulates part of my stylesheet.

    Now, to access those controls from the code for infoFlowContent.aspx,
    found in infoFlowContent.aspx.cs, in my Master Page code I have:

    Code:
    public string PopupVisText
        {
            set
            {
                PopupVis.Text = value;
            }
        }
    which exposes the controls, and in the infoFlowContent code I use something like

    Code:
    Master.PopupVisText = "hidden";
    to access them.

    Now, that all works nicely, but now I have a user control CacheControl.ascx
    used in infoFlowContent.aspx, and I need to access the same Master Page
    controls in the code associated with this user control, found in CacheControl.ascx.cs.

    I tried

    Code:
    Page.Master.PopupVisText = "hidden";
    but this keeps giving me
    Code:
    CS0117: 'System.Web.UI.MasterPage' does not contain a definition for 'PopupVisText'
    Looked around online for awhile and couldn't find anything useful, so any help would be much appreciated.
    You just have to cast your Master Page:

    ((MasterPage)Master).PopupVisText = "hidden";

    If your master page class has other name than MasterPage use it instead. By default this is the class name.

    Rodney Viana

  • #3
    New to the CF scene
    Join Date
    Jul 2007
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Literal Ltl = (Literal)Page.Master.FindControl("PopupVis");
    Ltl.Visible = false;


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •