Asp.net: gray from the text field with enabled = false, but you need to get the value

I want to disable the text box for the user.

But there is a value in the text box that I need to read.

So, I want a property readOnly(because I can read the value), but also want the gray window (function enabled = false) that the user sees, he does not have edit access to the text box.

What is the best way to do this?

+3
source share
4 answers

The @Keith attribute Readonlyfor the input field would be good. You can cut the text box by changing its background color.

+1
source

if your text box is html input text do the following:

    <input id="Text1" type="text" value="read me"  readonly="readonly" disabled="disabled" />

asp TextBox, :

    <asp:TextBox ID="TextBox1" runat="server"  ReadOnly ="true" Enabled="false"></asp:TextBox>
+6

Use Label instead, why do you use TextBox if you want to open editing for the user, and also change the color of the Label control.

-1
source

For me, the best way is to set the enabled = = property, but from jQuery:

$ ('# txtTotal') atr ('disabled', 'disabled') ;.

This way you can read the value in the code.

-1
source

All Articles