Troubles reference this pointer in external class file

  • Thread starter Thread starter PeterKellner
  • Start date Start date
P

PeterKellner

I'm wanting to reference page controls from a cs file in the app_code
directory. I'm getting a _Defaullt could not be found, missing
directive or assembly reference error. Very simple example below.

Default.aspx.cs:

using System;
using System.Web.UI;

public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}

protected void Button1_Click(object sender, EventArgs e)
{
Class1.UpdateButtonText(this);
}
}

----------------

Class1.cs

using System;

public class Class1
{
public Class1()
{
}

public static void UpdateButtonText(_Default global_Default)
{
}
}
Peter Kellner
http://peterkellner.net
 
This is impossible as the App_Code directory is compiled prior to your aspx
files.

-Brock
http://staff.develop.com/ballen
Thanks,

Makes sense to me now. When I moved Class2 directly into the aspx.cs
file it of course worked. Hadn't really thought about the order of
compilation.

-peter

----------------------------------------------------

using System;
using System.Web.UI;

public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
}

protected void Button1_Click(object sender, EventArgs e)
{
Class2.UpdateButtonText(this);
}
}


public class Class2
{
public Class2()
{
}

public static void UpdateButtonText(_Default global_Default)
{
throw new Exception("The method or operation is not
implemented.");
}
}
Peter Kellner
http://peterkellner.net
 
Back
Top