Richard...
one solution would be to use a session variable instead of strTest...
in VB:
session("test") = "changed_value"
rgds,
Octavio
-----Original Message-----
From: Richard McKinley [mailto:r.mckinley@k...]
Sent: Monday, January 21, 2002 6:17 PM
To: ASPX_Professional
Subject: [aspx_professional] Maintaining State of Page After Postbacks
Hi,
Can anyone point me in the direction of some resources which deal with how
to maintain the state of an ASP.NET page, after postback?
I have a form in an .asp page with 2 buttons and a label. One button
triggers an event handler to set a variable in the codebehind class.
Another tests if this variable value has been maintained by displaying its
contents to the label control. However, it appears that as soon as I
click the Test button which triggers another postback, the string variable
which was previously assigned a value - no longer exists..
Any help - gratefully received!
code sample follows:
public class CodeBehind : Page
{
private string strTest;
public Label Display;
public LinkButton btnSetVariable;
public LinkButton btnTestVariable;
public void Page_Load(Object Source, EventArgs E)
{
if (!Page.IsPostBack)
{
//init
strTest = "value";
}
}
// event handler called when btnSetVariable clicked
public void SetVariable( object sender, EventArgs e)
{
strTest = "changed_value";
}
// event handler called when btnTestVariable clicked
public void TestVariable( object sender, EventArgs e)
{
Display.Text = strTest;
}
}
$subst('Email.Unsub').