How to access the property of master page

Discussion in 'ASP .Net' started by RedHair, Mar 28, 2006.

  1. RedHair

    RedHair Guest

    I have a base page class A which inherits System.Web.UI.Page class
    then a aspx page B inherits class A and have a master page C.
    There is a property D (a string variable) in the master page C.

    How can I access the property D from the base page class A?

    PS: I know how to use reflection to access control of master page C from the
    base class A.
     
    RedHair, Mar 28, 2006
    #1
    1. Advertising

  2. RedHair

    Guest

    You must obtain a refrence to your MasterPage.
    Here is some Visual Basic code:

    dim myMaster As YourMasterPageType = CType( Me.Master,
    YourMasterPageType )
    myMaster.YourProperty = "lalalalal"
     
    , Mar 28, 2006
    #2
    1. Advertising

  3. RedHair

    clintonG Guest

    First of all, when working with MasterPages its more useful to refer to a
    "Content Page" rather than "base page class A."
    Secondly, we strongly type the Master by including the following in a
    content page...

    <%@ MasterType VirtualPath="~/Masters/Whatever.master" %>

    We can then access controls in the MasterPage using one of two techniques:

    * Early Bound: properties
    * Late Bound: FindControl method

    I really haven't tried to reuse a variable declared in the MasterPage from a
    Content Page.

    <%= Clinton Gallagher



    "RedHair" <> wrote in message
    news:...
    >I have a base page class A which inherits System.Web.UI.Page class
    > then a aspx page B inherits class A and have a master page C.
    > There is a property D (a string variable) in the master page C.
    >
    > How can I access the property D from the base page class A?
    >
    > PS: I know how to use reflection to access control of master page C from
    > the base class A.
    >
     
    clintonG, Mar 28, 2006
    #3
  4. RedHair

    RedHair Guest

    The reason I want to work with master page from the base page class A is
    because
    sometimes the master page will be a little bit different depends on the
    asp.net page.
    I need to pass the parameters from base page class to master page since all
    aspx
    pages inherit the base page class, I don't need to call the subroutine in
    each page.


    "clintonG" <> wrote in message
    news:%...
    > First of all, when working with MasterPages its more useful to refer to a
    > "Content Page" rather than "base page class A."
    > Secondly, we strongly type the Master by including the following in a
    > content page...
    >
    > <%@ MasterType VirtualPath="~/Masters/Whatever.master" %>
    >
    > We can then access controls in the MasterPage using one of two techniques:
    >
    > * Early Bound: properties
    > * Late Bound: FindControl method
    >
    > I really haven't tried to reuse a variable declared in the MasterPage from
    > a Content Page.
    >
    > <%= Clinton Gallagher
    >
    >
    >
    > "RedHair" <> wrote in message
    > news:...
    >>I have a base page class A which inherits System.Web.UI.Page class
    >> then a aspx page B inherits class A and have a master page C.
    >> There is a property D (a string variable) in the master page C.
    >>
    >> How can I access the property D from the base page class A?
    >>
    >> PS: I know how to use reflection to access control of master page C from
    >> the base class A.
    >>

    >
    >
     
    RedHair, Mar 29, 2006
    #4
  5. RedHair

    Guest

    Oops my bad, I have missunderstood your question.

    I thought you want to access variables from the content page.
     
    , Mar 29, 2006
    #5
  6. RedHair

    mfcmfc

    Joined:
    Mar 15, 2007
    Messages:
    1
    Did you ever find a resolution to this problem? I am looking for a solution myself.
     
    mfcmfc, Mar 15, 2007
    #6
    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. RedHair
    Replies:
    5
    Views:
    6,914
  2. =?Utf-8?B?SmF5IFBvbmR5?=
    Replies:
    6
    Views:
    492
    =?Utf-8?B?SmF5IFBvbmR5?=
    Nov 14, 2007
  3. Nathan Sokalski
    Replies:
    25
    Views:
    1,445
    Nathan Sokalski
    Mar 4, 2010
  4. SerpentKiss2010
    Replies:
    0
    Views:
    2,499
    SerpentKiss2010
    Apr 6, 2011
  5. RedHair
    Replies:
    5
    Views:
    304
Loading...

Share This Page