Accessing MasterPage Properties from a usercontrol on a contentpage??

Discussion in 'ASP .Net' started by wildman@noclient.net, Feb 26, 2008.

  1. Guest

    RE: Accessing MasterPage Properties from a usercontrol on a
    contentpage??


    On my master page's codebehind I have this property:


    Public Property ErrorMsg() As String
    Get
    Return ErrorLabel.Text
    End Get
    Set(ByVal value As String)
    ErrorLabel.Text = value
    End Set
    End Property


    I've got this on the contentpage,


    <%@ MasterType VirtualPath="ShapeUp.master" %>


    and I confirmed I can can set the property from the content page.

    However on my content page, I have a user control

    From inside that user control, I can see all the other properties from
    Page.Master , but not ErrorMsg I created on the master page
    codebehind.

    Also, I've tried this, but it does not work

    Dim errorMsg As Label = CType(Page.Master.FindControl("ErrorMsg"),
    Label)
    errorMsg.Text = "xxxx"

    Do I have no choice but to code event handling?


    Thanks for any help or information.
     
    , Feb 26, 2008
    #1
    1. Advertising

  2. Masudur Guest

    Re: Accessing MasterPage Properties from a usercontrol on acontentpage??

    On Feb 26, 7:16 am, wrote:
    > RE: Accessing MasterPage Properties from a usercontrol on a
    > contentpage??
    >
    > On my master page's codebehind I have this property:
    >
    > Public Property ErrorMsg() As String
    > Get
    > Return ErrorLabel.Text
    > End Get
    > Set(ByVal value As String)
    > ErrorLabel.Text = value
    > End Set
    > End Property
    >
    > I've got this on the contentpage,
    >
    > <%@ MasterType VirtualPath="ShapeUp.master" %>
    >
    > and I confirmed I can can set the property from the content page.
    >
    > However on my content page, I have a user control
    >
    > From inside that user control, I can see all the other properties from
    > Page.Master , but not ErrorMsg I created on the master page
    > codebehind.
    >
    > Also, I've tried this, but it does not work
    >
    > Dim errorMsg As Label = CType(Page.Master.FindControl("ErrorMsg"),
    > Label)
    > errorMsg.Text = "xxxx"
    >
    > Do I have no choice but to code event handling?
    >
    > Thanks for any help or information.


    Hi...

    did you tried casting the Page.Master to your class
    code in c# will look like this
    string msg = (Page.Master as ShapeUp).ErrorMsg;

    Masudur
    www.munna.shatkotha.com
    www.shatkotha.com
     
    Masudur, Feb 26, 2008
    #2
    1. Advertising

  3. Guest

    Re: Accessing MasterPage Properties from a usercontrol on acontentpage??

    Thanks. I tried this, but it never set the property on the master's
    ErrorMsg.

    Dim msg As String = TryCast(Page.Master, Master_Shapeup).ErrorMsg
    msg = "WTF"

    Note: If I simply do

    Master.ErrorMsg from the contentpage where the control lives it sets
    it.

    Am I going to have to do this with event handling? If so, I'm not sure
    how.
     
    , Feb 26, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    1
    Views:
    512
    Scott Allen
    Nov 22, 2005
  2. User
    Replies:
    9
    Views:
    10,463
  3. dawg1998
    Replies:
    2
    Views:
    3,644
    zehramb
    May 31, 2010
  4. =?Utf-8?B?ZGF3ZzE5OTg=?=
    Replies:
    0
    Views:
    500
    =?Utf-8?B?ZGF3ZzE5OTg=?=
    Mar 15, 2006
  5. Replies:
    7
    Views:
    13,275
    TuckWong
    Jan 11, 2013
Loading...

Share This Page