ASP.NET 2.0 Master Page public properties

  • Thread starter Thread starter Joel Reinford
  • Start date Start date
J

Joel Reinford

I am attempting to learn how to use Master Pages in ASP.NET 2.0 and am
having no success in getting the content page to see the public properties
in the master page. I am using code beside and have tried both with and
without namespace references.

Can anyone give me any suggestions on what I need to do to make the master
page public properties accessible to the content page?

Joel Reinford
Data Management Solutions LLC
 
Hey Joel,

The best way to understand the master pages is to assume that it is a kind
of user control. So if you try to access the variables in the master page
using page_load event of the other page (say, webform1.aspx), you will not be
successful in doing that.

What you need to do is to use, the page_init method in the webform1.aspx and
access the variables as...

Response.write(CType(Me.Master, MasterPage).VariableName)

HTH!
 
Thanks Remy

This thread got me headed in the right direction. The answer is to put an
@MasterType declaration in the content pages. It has this form:
<%@ MasterType VirtualPath="~/default.master" %>

Once that's been done, I can access the properties of the master page.

Joel Reinford
Data Management Solutions LLC
 
Back
Top