Disabled TextBox

  • Thread starter Thread starter Guest
  • Start date Start date
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
 
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...
 
Back
Top