Code for Accessing the controls of masterpage in its content page

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.
 
E

Eliyahu Goldin

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
 

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,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top