I am having problem postback, (code shown below) the variable "my_str" is
lost after clicking the "submit" button. Isn't it suppose to display
"changed" after posting back? Is there anyway I can maintain the state of
a variable?
Imagine the variable is a Class, not String. After clicking the submit
button, I updated some properties in the instance of the class. How do I use
the updated class instance after submitting the form? Help...
<%@ Page %>
<script language="c#" runat="server">
String my_str;
void Page_Load () {
if (!Page.IsPostBack)
my_str = "hello";
else
debug.Text = "debug=" + my_str;
}
public void submit_me (object sender, EventArgs e) {
my_str = "changed";
}
</script>
<form runat="server">
<asp:button runat="server" onClick="submit_me" text="submit"/>
<asp:literal runat="server" id="debug"></asp:literal>
</form>
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.591 / Virus Database: 374 - Release Date: 2/18/2004