Troubles reference this pointer in external class file

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
 
B

Brock Allen

This is impossible as the App_Code directory is compiled prior to your aspx
files.
 
P

PeterKellner

This is impossible as the App_Code directory is compiled prior to your aspx
files.
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
 

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,994
Messages
2,570,223
Members
46,814
Latest member
SpicetreeDigital

Latest Threads

Top