How to access public member variable in the parent page class from a Web User Control

Joined
Mar 3, 2009
Messages
2
Reaction score
0
The title pretty much says my problem.

I have a .aspx main page

- index.aspx.cs

public partial class IndexPageClass : System.Web.UI.Page
{
public string m_strCustomerName = "abc";
.
.
.
}

- In index.aspx, I need to display it in a list.

<%@ Register Src="signin.ascx" TagName="signin" TagPrefix="uc2" %>
<li><b><a>Hi, <%=m_strCustomerName%></a></b></li>


So in my signin.ascx user control, when the customer logs in, I will get the customer name and want to update it in main index.aspx page. But I haven't found an easy way to do it except to use session variable which is kinda strange to me. (It should work though)

Casting doesn't work.
IndexPageClass bp = (IndexPageClass)this.Page;
Error I got:

"Unable to cast object of type 'ASP.index_aspx' to type 'IndexPageClass'.
Description: An unhandled exception occurred during the execution of the current web request. Exception Details: System.InvalidCastException: Unable to cast object of type 'ASP.index_aspx' to type 'IndexPageClass'."

I know 'ASP.index_aspx' is a class created by .Net:

public class index_aspx : global::thebcguide.IndexPageClass, System.Web.IHttpHandler

Is there any way I can cast or access my 'IndexPageClass' class? I am frustrated. Any serious help would be appreciated.
 

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

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top