Why is my ascx control begin cast to ASP."classname"?

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top