ASP.Net persist readonly textbox value on postback

Author: | Categories: Programming No Comments

As a security measure in the asp.net the readonly fields and disabled fields loose their values in postbacks. To retain the readonly textbox value after postback instead of making the textbox readonly using properties option, use attributes in code:


TextBox1.Attributes.Add(“readonly”, “readonly”);


that will still make the textbox readonly and will also retain the value after each postback

Leave a Reply

Your email address will not be published.