I have the following issue: I create a TextBox dynamically in my web page, its value is "initialVal" in the beginning. Now I need to make a postback (not callback) to the server, and during this operation, I need to compute/change the value of my textbox to other value.
Here's an example:
protected void Page_Load(object sender, EventArgs e)
{
TextBox txtBox = new TextBox();
txtBox.ID = "newButton";
form1.Controls.Add(txtBox);
txtBox.Text = "initialVal";
if (IsPostBack && Session["change"] == null)
{
txtBox.Text = "change";
Session["change"] = true;
}
}
The problem: even if I change the value via code, the textbox will keep the text "initialVal". I feel this is something related to the view state, but I don't understand. Coudl anyone please help me here?
Thanks.
Aucun commentaire:
Enregistrer un commentaire