ASP.NET 2.0 Master Page public properties

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
 
G

Guest

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!
 
J

Joel Reinford

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,161
Latest member
GertrudeMa
Top