Disabled TextBox

G

Guest

i have a textbox server control whos value is being changed using javascript.
when the text is changes and i post back to the server the Text change is
not reflected, instead i get blank string.
if the TextBox enabled property is set to true , everything works fine.
any ideas?
thanks in advance
 
M

Mark Rae

i have a textbox server control whos value is being changed using
javascript.
when the text is changes and i post back to the server the Text change is
not reflected, instead i get blank string.
if the TextBox enabled property is set to true , everything works fine.
any ideas?

Yep - this is, ahem, "standard" behaviour... :)

Thankfully, the solution is simple enough, though: don't set the textbox
readonly property in the HTML markup - do it in code instead. E.g.

Don't do this:
<asp:TextBox = ID="MyTextBox" runat="server" Enabled="false" />

Do this instead:
<asp:TextBox = ID="MyTextBox" runat="server" />

And in the page's Page_Load event, do this:
MyTextBox.Attributes.Add("disabled", "true");


It's the same with the readonly attribute...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top