I found a problem on ASP.net web Applications with read only text boxes not responding to the ‘viewsate’ property set, If you set the ‘readonly’ attribute to true. It will clear the readonly text box text up on postback.

<asp:TextBox ID=”companyTextBox” runat=”server” InvalidColor=”#ff0000″
MinimumPrefixLength=”3″ EnableViewState=”true” ReadOnly=”true”/>

The solution for avoiding clearance was to add the ‘readonly’ property at the run time on the event of each page load.

protected void Page_Load(object sender, EventArgs e)
{

this.companyTextBox.Attributes.Add(“ReadOnly”, “true”);

}

At the moment  I cannot understand how this happens. But will find out soon.