What's the difference between the Enabled and the ReadOnly-properties of an asp:TextBox control?
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.
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.
You can make the TextBox as read-only by setting the readonly attribute to the input element.
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.
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.
Another behaviour is that readonly = 'true'
controls will fire events like click
, buton Enabled = False
controls will not.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With