Bernard
Bernard

Reputation: 2043

Getting access to a custom Master page from a user control

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

Answers (2)

etc
etc

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

Related Questions