Sometimes you want to set a textbox to read only because you don't want the user to change the value inside. This is the case when the value in the textbox is, for example, the date the user has selected from a calendar control, or the result of some calculation.
To make the textbox read only, you would normally set the ReadOnly attribute to True or enabled = false in the .aspx page.
However, if you want to process this value on the server (e.g. save it to a database), the value is not recognised. This is because the server does not process read only values.
To fix this, set the following in the code behind, for example:
txt.Attributes.Add("readOnly", "true")
Tuesday, May 20, 2008
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment