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
    • Loading...
    • jliberty
    • Joined on 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
    • Loading...
    • BrockAllen
    • Joined on 05-05-2003, 2:46 PM
    • Providence, RI
    • Posts 1,251
     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
    • Loading...
    • jliberty
    • Joined on 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

    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
    • Loading...
    • taniam
    • Joined on 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

    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)
Microsoft Communities
Page view counter