Anyname Donotcare
Anyname Donotcare

Reputation: 11403

Unable to cast object of type 'ASP.XXX_master' to type 'XXX.MasterPage'

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

Answers (1)

David d C e Freitas
David d C e Freitas

Reputation: 7511

Make sure you have used the same master page on that page as the one you are casting to.

Upvotes: 2

Related Questions