Reputation: 2043
We have created a Master page that inherits off the asp.net Master class. We have also got ui controls that inherit off the standard asp.net ui control class. Our Master page has a public member variable. We need to be able to access that member variable from the ui controls that we use. However we can't seem to get at it? Is it our architecture that is wrong? Or the idea itself - user control getting acces to Master page variables?
Upvotes: 6
Views: 2204
Reputation: 630
Generally speaking, this is probably not a great design pattern. However, you should be able to do something like this:
MyMasterType myMaster = this.Page.Master as MyMasterType;
if (myMaster != null)
{
myMaster.PublicProperty = value;
}
Upvotes: 6
Reputation: 3837
Here you go: http://msdn.microsoft.com/en-us/library/xxwa0ff0.aspx
from: Accessing masterpage properties from child pages in ASP.net VB
Upvotes: 0