Reputation: 11403
I want to access a specific control in a master page from the page which use it so i write the following code line :
this.Master.FindControl("pnl_Buttonss").Visible = false;
Now
I get the following exception from the page .designer.cs :
Unable to cast object of type 'ASP.masterpage2_master' to type 'GuideUI.MasterPage'.
public new GuideUI.MasterPage Master {
get {
return ((GuideUI.MasterPage)(base.Master));
}
}
this 's the code which throw the exception .How to fix this error
Upvotes: 2
Views: 2547
Reputation: 7511
Make sure you have used the same master page on that page as the one you are casting to.
Upvotes: 2