1

I have searched for two days now to find a solution to this problem and I can't seem to find anything that works for me. I have a LinkButton that is disabled when the page loads. I am disabling the button like this:

$("#BtnSubmit").prop("disabled", true);
$("#BtnSubmit").removeAttr("enabled");

When the user fills out all of the required fields, I am attempting to re-enable the LinkButton like this:

 $("#BtnSubmit").removeAttr("disabled");

However, this does not work. I have looked at the generated markup, and it seems that the LinkButton has its href attribute removed when it is set to disabled. Simply removing the disabled attribute does not work. I have also tried adding the enabled attribute like this:

$("#BtnSubmit").attr("enabled", "true");

However, this doesn't work either.

What am I missing? The button is clearly being re-enabled from a design perspective. It goes from its disabled appearance to its enabled appearance just fine, but it doesn't get its href attribute back. I've tried manually adding the href, but that also doesn't work. Most of the solutions I've found just cover how to disable the button; none of them seem to mention anything about re-enabling it. Any suggestions?

ic3man7019
  • 721
  • 6
  • 24

2 Answers2

2

It'd be good if you could provide us with your ASPX markup and its code behind in your post. There are many ways to disable/enable the button. Did you do it from via the server-side or client-side? My hunch is that you probably set Enabled property on your LinkButton to False, which explains why the href attribute was gone as well.

One approach you could consider is that you can register your client-side javascript code in Page_Load event, and when page reloads, the code will then be executed.

Something like this

var script = "$('#BtnSubmit').prop('disabled', true);";
ScriptManager.RegisterStartupScript(Page, GetType(), "mykey", "script", true);

Hope it helps.

woodykiddy
  • 6,074
  • 16
  • 59
  • 100
1

I had a similar problem, not long ago. This worked for me:

    $("#BtnSubmit").prop("disabled", true);
    $("#BtnSubmit").prop("disabled", false);

Note that the HTML property was set like this on page load:

<input type="submit" id="BtnSubmit" disabled="disabled"/>
Matthew Alltop
  • 501
  • 4
  • 20