Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

asp:TextBox ReadOnly=true or Enabled=false?

What's the difference between the Enabled and the ReadOnly-properties of an asp:TextBox control?

like image 909
Alf Avatar asked Oct 06 '08 13:10

Alf


People also ask

How do I make a TextBox read-only in asp net?

Use the ReadOnly property to specify whether the contents of the TextBox control can be changed. Setting this property to true will prevent users from entering a value or changing the existing value. Note that the user of the TextBox control cannot change this property; only the developer can.

How do you make a TextBox not editable in asp net?

Add("readonly", "readonly"); 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.

Which control is read-only control in asp net?

You can make the TextBox as read-only by setting the readonly attribute to the input element.

Which data control are read-only in asp net?

Enabled TextBox and ReadOnly TextBox ASP.Net TextBox control has similar two properties “Enabled” and “ReadOnly”. Both properties used to prevent a user from entering a value in textbox. The Enabled and ReadOnly make textbox field non-editable mode.


2 Answers

If a control is disabled it cannot be edited and its content is excluded when the form is submitted.

If a control is readonly it cannot be edited, but its content (if any) is still included with the submission.

like image 108
Adam Bellaire Avatar answered Sep 22 '22 13:09

Adam Bellaire


Another behaviour is that readonly = 'true' controls will fire events like click, buton Enabled = False controls will not.

like image 43
rodrigocl Avatar answered Sep 26 '22 13:09

rodrigocl