X
xs
I have a master page which has a class name "GlobalPage" created in Web
namespace.
I created a string property called connectionString in this GlobalPage
class.
I have a ascx control loaded in this GlobalPage which is working fine until
the day I need to access the connectionString property in the GlobalPage
from my ascx control. This is what I wrote :
this.connectionString = ((Web.GlobalPage)this.Page.Master).ConnectionString;
This compiles perfectly. However I received the following runtime error :
"An exception of type 'System.InvalidCastException' occurred in
App_Web_zjl86e8a.dll but was not handled in user code
Additional information: Unable to cast object of type 'ASP.GlobalPage' to
type Web.GlobalPage'."
I have the following declared at my master page and ascx respectively.
Master Page
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="GlobalPage.master.cs" Inherits="Web.GlobalPage"
ClassName="GlobalPage" %>
Ascx Control
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SideBar.ascx.cs"
Inherits="Web.SideBar" ClassName="SideBar"%>
Any help is appreciated. Thanks
namespace.
I created a string property called connectionString in this GlobalPage
class.
I have a ascx control loaded in this GlobalPage which is working fine until
the day I need to access the connectionString property in the GlobalPage
from my ascx control. This is what I wrote :
this.connectionString = ((Web.GlobalPage)this.Page.Master).ConnectionString;
This compiles perfectly. However I received the following runtime error :
"An exception of type 'System.InvalidCastException' occurred in
App_Web_zjl86e8a.dll but was not handled in user code
Additional information: Unable to cast object of type 'ASP.GlobalPage' to
type Web.GlobalPage'."
I have the following declared at my master page and ascx respectively.
Master Page
<%@ Master Language="C#" AutoEventWireup="true"
CodeFile="GlobalPage.master.cs" Inherits="Web.GlobalPage"
ClassName="GlobalPage" %>
Ascx Control
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="SideBar.ascx.cs"
Inherits="Web.SideBar" ClassName="SideBar"%>
Any help is appreciated. Thanks