ASP.NET ReadOnly Property

Definition and Usage

The ReadOnly property is used to set or return whether the text in the TextBox control can be changed.

If this property is set to TRUE, the text cannot be changed; otherwise, it is FALSE. The default is FALSE.

Syntax

<asp:TextBox ReadOnly="TRUE|FALSE" runat="server"/>

Example

The following example sets the ReadOnly property to "TRUE":

<form runat="server">
<asp:TextBox id="tb1" runat="server" ReadOnly="TRUE" 
Text="This text is read only" />
</form>

Example

Set the ReadOnly property of the TextBox control to TRUE