MasterPages and content pages

  • Thread starter Thread starter salportaro
  • Start date Start date
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,
 
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
 
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
 
Dim lbl As Label
lbl = CType(Master.FindControl("Label4"), Label)
lbl.Text = "whatever"
 
Back
Top