views:

399

answers:

1

I'm using a Substitution control in my master page, and I want to render a user control content (related to the login area of my website) in the Substitution . Seems like I must have a reference for the requested page so that it could render the control. But I need to render the control in the master page itself, as it's shared across multiple pages in my website. What are the guidelines to achieve that?

Tks

A: 

So you want to render a user control from your MasterPage code-behind, and add it to a Substitution that's also in the master page? Why do you need a reference to the page that's using the master?

Assuming your using VB and that I understand your question, try this in your MasterPage code-behind:

Dim someControl As MyControl = CType((New Page()).LoadControl("~/Path/To/MyControl.ascx"), MyControl)
mySubstitution.Controls.Add(someControl)
Cory Larson
The Substitution control that I'm referring is the http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.substitution.aspx, used for output cached pages. (:
Poco