proseidon
proseidon

Reputation: 2305

Making a textbox control uneditable without disabling it?

Is it possible to take a textbox item and make it un-editable while still having it enabled for use?

Textbox1.Enabled = false;

This works for all purposes I need EXCEPT that I can't read data from it because it's disabled. If this is not possible I can find alternate solutions. Making it invisible is also not an option.

Upvotes: 0

Views: 82

Answers (2)

Ricketts
Ricketts

Reputation: 5223

If you will be changing the textbox value via javascript and plan to read the changed value server side, you cannot use asp.net's readonly property. You need to set it like this:

Textbox1.Attributes["readonly"] = "readonly";

Reference: http://aspadvice.com/blogs/joteke/archive/2006/04/12/16409.aspx

Upvotes: 0

Adil
Adil

Reputation: 148110

You can use TextBox.ReadOnly

Textbox1.ReadOnly = false;

Upvotes: 4

Related Questions