Dzung Dakao

Dzung Dakao

  • NA
  • 17
  • 3.1k

App_Code folder

Oct 23 2017 12:59 PM
Hi,
 
I have created a simple project (website) using asp.net. The project has a default page (Default.aspx) and a class (Class1.cs). Class1.cs resides inside a folder called App_Code.
 
The Default.aspx page has a button and a label. On a click of the button, I'd like to populate the label with a text of "hello world".
 
The text (hello world) is comming from a method called "foo" which resides in Class1.cs.
 
When I run it locally (http://localhost:8080/Default.aspx), it works fine.  But, when I upload it to the webserver, and run it from browser, it doesn't work.  
 
Here is the error message generated from the server: The name 'Class1' does not exist in the current context 
 
My code:
 
protected void Button1_Click(object sender, EventArgs e)
{
      Label1.Text = Class1.foo();
}
 
public static string foo()
{
      return "hello world";
}
 
Please help!
 
thanks 
 
 
 
 
 

Answers (1)