S
- Steve -
I have a cs file I use in an ASP.NET form. The class has several member
variables. If I assign a value to those variables in a method, when I get
to another method the variable no longer equals what it was assigned.
For example:
namespace test
{
public class testClass : Page
{
protected String testString;
private void btnEmail_Click(object sender, System.EventArgs e)
{
testString = "testing";
}
private void btnShow_Click(object sender, System.EventArgs e)
{
//What will print here is "testString equals - " and that is it.
lblMessage.Text = "testString equals - " + testString;
}
}
in the btnShow_Click shouldn't testString equal "testing" from when it was
assigned in btnEmail_Click? Everything works fine with similiar code in a
console C# application. I'm really confused on what I'm screwing up. (ps
I'm new to ASP.NET)
variables. If I assign a value to those variables in a method, when I get
to another method the variable no longer equals what it was assigned.
For example:
namespace test
{
public class testClass : Page
{
protected String testString;
private void btnEmail_Click(object sender, System.EventArgs e)
{
testString = "testing";
}
private void btnShow_Click(object sender, System.EventArgs e)
{
//What will print here is "testString equals - " and that is it.
lblMessage.Text = "testString equals - " + testString;
}
}
in the btnShow_Click shouldn't testString equal "testing" from when it was
assigned in btnEmail_Click? Everything works fine with similiar code in a
console C# application. I'm really confused on what I'm screwing up. (ps
I'm new to ASP.NET)