Saturday, February 6, 2010

How to get the readonly textbox value on the server

The ReadOnly TextBox will ignore the submitted text , this change due to security reasons .

For example you want to use the textbox and you don't want to let the user to change the textbox manually , now the problem is that the selected value will not be
accepted by the textbox when the user submit the form , because the textbox is in readonly mode ,
in this case you need to manually set the submitted textbox value , you can easily use the values that is submitted via form collection ,

something like this:

Protected void Page_Load(object Sender,EventArgs e)
{
TextBox1.Text = Server.HtmlEncode(Request.Form(TextBox1.UniqueID))
}

No comments: