Some of my users reported me problems that the ASP.NET application hangs out and won't go on in IE (in Chrome, Firefox, Edge, Safari - it is working!). The thing is that when the user clicks on the button, it should be disabled while the content is loaded, so I disable the button with OnClientClick and then continue with the OnClick function in C# background. But only in IE it isn't working! The button is disabled, but after that nothing happens, the application doesn't continue.
I tried with disabling the button from C#, from jquery, from functions... But it's always the same!
Any ideas?
<asp:LinkButton ID="GoButton" runat="server" Text="<div></div>" CssClass="Go" OnClick="GoButton_Click" OnClientClick="return disablebutton(this);" />
<script>
function disablebutton(btn) {
$(btn).attr("disabled", "disabled");
return true; }
</script>
To disable a LinkButton which has Enabled="false"
, ASP.NET removes the href
attribute of the anchor element. In order to allow the postback to occur, you can remove the attribute asynchronously with setTimeout
:
function disablebutton(btn) {
setTimeout(function () { btn.removeAttribute('href'); }, 10);
return true;
}
Make sure that the Enabled
and OnClick
properties are not modified in code-behind, so that the LinkButton is enabled and works correctly after the postback.
Rather than attempting to disable it, you can just remove it's click event.
Try this:
function disablebutton(btn) {
$(btn).bind('click', false);
return true;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.