Reputation: 2751
I am trying to get a master's page instance without cast.
Something like this but without cast
var masterPage = (MasterPageName)Page.Master;
if (masterPage != null) {
masterPage.Foo = false;
}
Is there any workaround for this?
thanks
Upvotes: 1
Views: 523
Reputation: 44605
I would make MasterPageName to implement an interface IFoo which has the boolean Foo defined, so in your code above you could check if Page.Master is IFoo and you do not need any cast.
Upvotes: 1