Unable to cast object of type 'X' to type 'X' - ASP.NET

后端 未结 6 1584
时光取名叫无心
时光取名叫无心 2020-12-11 19:12

I am currently working with a ASP.NET Web site project in Visual Studio 2008 and everytime I make a change to code behind page for a user control and browse to page that is

6条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-11 19:59

    Eurekaaa!! Got it... This one works...

    When you grag drop the usercontrol or load it via the LoadControl method use a 'tilde' in its path. E.g. this.LoadControl("~/MyUserControl.ascx");

    The same applied for a control dropped on a page. Add the tilde to the declarative path of the user control in the aspx page.

    We can call this as a bug in VS2005 and is fixed in VS 2008.

    Reply me if this dosen't work or needs more explanation. Alternatively, don't forget to mark this as answer.

提交回复
热议问题