Code for Accessing the controls of masterpage in its content page

  • Thread starter Thread starter Sonu
  • Start date Start date
S

Sonu

I have to change the controls (panel)'s top and other properties of
master page after accessing it in it's content page.
 
Use this line
<%@ MasterType virtualpath="myMasterPage.master" %>
to access public properties of the master page from the content page.

Note, that the controls in .aspx file are protected and not public. You can
make a public property like
public Panel MyPanel {get{return myPanel;}}
where myPanel is defined in the markup as
<asp:Panel runat="server" id="myPanel" />

But a much better practice would be to make a public method in the master
page that will set the panel properties according to the parameters you will
pass from the content page.

And consider setting position properties on client side.

--
Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
 
Back
Top