G
Guest
I have a page Default.aspx. Its first line is the following:
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="default.aspx.cs"
Inherits="MyCompany.MyApp.default" Title="Untitled Page" %>
The first line in MasterPage.master is the following:
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MyCompany.MyApp.masterpage" %>
In the MasterPage.master.cs file I am declaring a public property as follows:
public MyCompany.MyApp.Controls.RelatedMenu MenuRelated
{
get { return this.RelatedMenu1; }
}
In the default.aspx.cs in Page_Load method I have the following line:
((masterpage)this.Master).MenuRelated.MenuItems = "select~add";
Some times (not always) this line throws an InvalidCastException and its
message says
Unable to cast ASP.masterpage_master to MyCompany.MyApp.masterpage
Any ideas why?
Thanks
<%@ Page Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="default.aspx.cs"
Inherits="MyCompany.MyApp.default" Title="Untitled Page" %>
The first line in MasterPage.master is the following:
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="MasterPage.master.cs" Inherits="MyCompany.MyApp.masterpage" %>
In the MasterPage.master.cs file I am declaring a public property as follows:
public MyCompany.MyApp.Controls.RelatedMenu MenuRelated
{
get { return this.RelatedMenu1; }
}
In the default.aspx.cs in Page_Load method I have the following line:
((masterpage)this.Master).MenuRelated.MenuItems = "select~add";
Some times (not always) this line throws an InvalidCastException and its
message says
Unable to cast ASP.masterpage_master to MyCompany.MyApp.masterpage
Any ideas why?
Thanks