MasterPages and content pages

S

salportaro

Question:

Is there a way of manipulating a master page element from a content
page? For example, if I have lblStatus on the masterpage and I call
anypage.aspx, can I set lblStatus from anypage?

Thanks,
 
R

Ray Costanzo [MVP]

Hi salportaro,

Add this to your ASPX file:
<%@ MasterType VirtualPath="~/path/to/file.master" %>

Then, in your code, you can use:

this.Master.[whatever]

Ray at work
 
E

Eliyahu Goldin

Yes. If you put a line

<%@ MasterType virtualpath="~/myMasterPage.master" %>

to the .aspx file of the content, you will be abble to access all public
members of the master as this.Master.myProperty
 
A

AugustWind

Dim lbl As Label
lbl = CType(Master.FindControl("Label4"), Label)
lbl.Text = "whatever"
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top