I want to disable a textbox for a user.
But in the textbox is a value, that I need to read.
So I want the readOnly
property (because I can read the value), but also want to gray out the box (function of enabled = false
), that the user can see, he hasn't access to edit the textbox.
Which is the best way to do this?
You can gray out the text box by changing its background color. Save this answer. Show activity on this post. Use Label instead, why you are using TextBox if you want to open edit for user, also change the color of the Label control.
The disabled="disabled" parameter is the standard way to do this, and you could use something like jQuery to dynamically disable all of the form elements contained in a fieldset (Which is the standard way of grouping related form elements) on the fly.
if your text box is a html input text so do this:
<input id="Text1" type="text" value="read me" readonly="readonly" disabled="disabled" />
and if it's an asp TextBox then:
<asp:TextBox ID="TextBox1" runat="server" ReadOnly ="true" Enabled="false"></asp:TextBox>
@Keith setting Readonly
attribute to input box will be good. You can gray out the text box by changing its background color.
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