About the author

Vijay Kodali
E-mail me Send mail

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2024

Read-only Textbox View state problem in ASP.NET

For a Textbox with Read-only property set to true, text is not be posted back to the server side.

From MSDN..

The Text value of a TextBox control with the ReadOnly property set to true is sent to the server when a postback occurs, but the server does no processing for a read-only text box. This prevents a malicious user from changing a Text value that is read-only.

To set a Textbox read-only and keep the text on post back, use the following code..

We can get it from the Request object as shown below…

  TextBox1.Text = Request[TextBox1.UniqueID]; //Another approach… 
  TextBox1.Text = Request.Form[TextBox1.ClientID.Replace("_", "$")];

Posted by vijay on Tuesday, July 31, 2007 2:20 PM
Permalink | Comments (2) | Post RSSRSS comment feed