Properties in master pages

Last post 12-19-2005 6:29 PM by JoeReynolds. 5 replies.

Sort Posts:

  • Properties in master pages

    05-12-2005, 1:20 PM
    • Member
      45 point Member
    • jliberty
    • Member since 11-15-2002, 7:05 AM
    • Acton, MA
    • Posts 9
    • TrustedFriends-MVPs

    In previous CTP's it was possible to declare a public property in a master page, and then access that property using Master.<propertyname> from the content page. IN fact, the documentation of MasterPage Class says:

     All public properties in the master page class are available to the content page's base class through the Master property, using the notation Master.PropertyName.

    This no longer seems to work. Is this a bug, or am I doing something wrong?

    Thanks.

    jliberty@libertyassocaites.com 

    Jesse Liberty
  • Re: Properties in master pages

    05-12-2005, 2:00 PM
    • Contributor
      6,299 point Contributor
    • BrockAllen
    • Member since 05-05-2003, 2:46 PM
    • Providence, RI
    • Posts 1,255
     jliberty wrote:

    In previous CTP's it was possible to declare a public property in a master page, and then access that property using Master.<propertyname> from the content page. IN fact, the documentation of MasterPage Class says:

     All public properties in the master page class are available to the content page's base class through the Master property, using the notation Master.PropertyName.

    This no longer seems to work. Is this a bug, or am I doing something wrong?

    You need to add either one of these to the page:

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

    <%@ MasterType TypeName="YourMasterBaseClass" %>

    -Brock

     

    DevelopMentor
    http://staff.develop.com/ballen
  • Yes [Yes] Re: Properties in master pages

    05-12-2005, 8:49 PM
    • Member
      45 point Member
    • jliberty
    • Member since 11-15-2002, 7:05 AM
    • Acton, MA
    • Posts 9
    • TrustedFriends-MVPs
    You are terrific; that did it, thanks!
    Jesse Liberty
  • Re: Properties in master pages

    12-18-2005, 1:04 AM
    • Participant
      781 point Participant
    • JoeReynolds
    • Member since 06-24-2002, 11:39 AM
    • Posts 238

    I have the master type directive on a content page but cannot reference master page public items in the codebehind.

    <%=Master.MyVariable%> works from the design view but

    response.write(Master.MyVariable) in the codebehind

    produces nothing.

    Any help would be appreciated.

  • Re: Properties in master pages

    12-19-2005, 6:19 PM
    • Participant
      785 point Participant
    • taniam
    • Member since 11-04-2002, 7:21 PM
    • Posts 155
    • AspNetTeam
    When you say that having the Master.MyVariable in the codebehind produces nothing, do you mean that there are no compilation errros, but nothing is output? 
    Tania

    ASP.NET Team



    This posting is provided "AS IS" with no warranties, and confers no rights.
  • Re: Properties in master pages

    12-19-2005, 6:29 PM
    • Participant
      781 point Participant
    • JoeReynolds
    • Member since 06-24-2002, 11:39 AM
    • Posts 238

    No compilation errors. You will note I said <%=Master.MyVariable%> works on the aspx page.

    I have fould it is a loading sequence issue.

    If I use Private Sub PreInit rather than Load then I can access the Master variables via Master.MyVariable in the code file.

    Is there any documentation where all of this is spelled out?

    Is it possible to use a BasePage with a Master page? BasePage properties can be accessed directly.

Page 1 of 1 (6 items)