Reputation: 2027
I have an ASPX form with a TextBox object.
It is defined in the code behind as public TextBox UI_Delegate1;
and in the ASPX form as <ASP:TextBox id="UI_Delegate1" runat="server" />
At the Page_Load
member in the code behind, I make the assignment:
UI_Delegate.Text = "AnyText";
The rendered HTML text for this control is:
<input name="UI_Delegate1" type="text" value="AnyText" id="UI_Delegate1" />
Within the form, I have a button with this definition:
<button type="submit" onserverclick="SubmitChanges" runat="server">Submit Changes</button>
I then type text in the TextBox, to modify the "AnyText" value to some other text and then click the Submit Changes button, but the value of UI_Delegate1.Text in the code behind SubmitChanges member after clicking the button continues to be "AnyText", no matter what I type.
In other words, it seems that ASPX is considering this control as readonly, but I have not set such attribute anywhere.
What could be the possible reasons for this behaviour?
Upvotes: 0
Views: 554
Reputation: 2714
As @Yuriy said, make the following change in Page_Load:
if(!IsPostBack)
{
UI_Delegate1.Text = "AnyText";
}
Upvotes: 3