Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

User Control accessing MasterPage elements?

Status
Not open for further replies.

euntair

Programmer
Sep 13, 2007
53
US
How can I access MasterPage html elements from a User Control click event? I have tried:

in master page
<div id="menu" runat="server"></div>

in click event for control:
UserControl uc = (UserControl)LoadControl("a.ascx");
Page.FindControl("menu").Controls.Add(uc);
 
I'd create a Public Property. An example of how to do this can be seen here:



-------------------------------------------------------

Mark,
[URL unfurl="true"]http://aspnetlibrary.com[/url]
[URL unfurl="true"]http://mdssolutions.co.uk[/url] - Delivering professional ASP.NET solutions
[URL unfurl="true"]http://weblogs.asp.net/marksmith[/url]
 
Thanks for your help. I found Page.Master.FindControl but past the first dynamic control assigned it is acting weird.

I have four div where I am dynamically assigning user controls when the page first loads header, menu, work and footer. Header has a linkbutton that loads a uc into menu. Menu in turn has a linkbutton that loads a uc into work. But the linkbutton in menu is clearing menu and work. The code is the same for both header and menu.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top