Jagd
Jagd

Reputation: 7306

Disabled textbox and ViewState woes

I have an asp.net textbox that is disabled:

<asp:TextBox ID="txtEmpName" runat="server" Enabled="false"></asp:TextBox>

Using jQuery, I then enable or disable the textbox depending upon two radio buttons that are clicked.

$(document).on("change", "input[id*='_rbtnIsFullTime_']", function ($e) {
  if ($(this).val() == "1")
    $("input[id$='_txtEmpName']").removeAttr('disabled');
  else
    $("input[id$='_txtEmpName']").attr('disabled', 'disabled');
});

The problem that I am running into is when the textbox is enabled via jQuery, any text that is then entered into it by the user is not submitted with the page because the ViewState still shows the textbox as being disabled when the page was originally rendered.

Any ideas on how to get around this and make the ViewState play nicely with jQuery?

Upvotes: 0

Views: 274

Answers (1)

Dutchie432
Dutchie432

Reputation: 29160

Create a second textbox with the same text and make ti disabled. Then just toggle the visibility of the two boxes accordingly?

Upvotes: 1

Related Questions