Saturday, October 10, 2009

The changed values of a read only or disabled text box is not retained after postback

ScenarioThe changed values of a read only or disabled text box is not retained after postback.
Reason : Browser is not maintaining the state of a read only or disabled control.
Solution: The values of all the form controls are maintained inside Request.Form. So include the following code snippet inside page load to retain the values dynamically in the textbox.
Inside Page_Load
if(IsPostBack)
TextBox1.Text = Request.Form(this.TextBox1.ClientID);

No comments:

Post a Comment