Access Parent Method from user web control

  • Thread starter Thread starter Mo
  • Start date Start date
M

Mo

Hi,

I am not sure if this is the right group but I have a web control
within a page and I am trying to access a method from the control. My
master page is set as :

public partial class _Default : System.Web.UI.Page
{
private string Cart = "";
public string GetCart
{
get { return Cart;}
set { Cart = value; }
}
protected void Page_Load(object sender, EventArgs e)
{


}
}

in the control page I am trying to access the GetCart method by using

((Default)this.Page).GetCart = "Somrthinghere";

I am getting the error:

Type or namespace name 'Default' could not be found (are you missing a
using directive or an assembly
reference?) C:\Projects\AtlasWebSite1\WebUserControl.ascx.cs

What am I doing wrong?
 
If I understand your problem correctly I think I have the solution for
you:

In your ASP page add the follow tag:

<%@ MasterType VirtualPath="~/Default.master" %>

This will let the system know the context for the master page, so
instead of using the default implementation it will have your custom
methods available to you.

Kelly S. Elias
Webmaster
DevDistrict - C# Code Library
http://devdistrict.com
 
Back
Top