I have a set of ASP.NET controls:
<asp:LinkButton ID="Find"
ClientIDMode="Static"
runat="server"
CausesValidation="true"
OnClientClick="$('#Find').attr('disabled', 'disabled'); $('#SearchingLabel').show();">
<span>Search</span>
</asp:LinkButton>
<asp:Label ID="SearchingLabel"
ClientIDMode="Static"
runat="server"
Text="Searching..."
style="display: none;" />
and as you can see I'm consuming the OnClientClick
so that I can disable the Find
button and show the SearchingLabel
(and the JavaScript works without error BTW). Pretty basic stuff.
Further, surrounding the CausesValidation
attribute, I do have validation controls on the page, but there are no current validation errors.
However, even though I'm not returning false
from the JavaScript the page isn't posting back. I've even attempted to return true;
but that didn't change anything (not really that surprising but it was worth a try).
I look forward to your feedback!
I have a set of ASP.NET controls:
<asp:LinkButton ID="Find"
ClientIDMode="Static"
runat="server"
CausesValidation="true"
OnClientClick="$('#Find').attr('disabled', 'disabled'); $('#SearchingLabel').show();">
<span>Search</span>
</asp:LinkButton>
<asp:Label ID="SearchingLabel"
ClientIDMode="Static"
runat="server"
Text="Searching..."
style="display: none;" />
and as you can see I'm consuming the OnClientClick
so that I can disable the Find
button and show the SearchingLabel
(and the JavaScript works without error BTW). Pretty basic stuff.
Further, surrounding the CausesValidation
attribute, I do have validation controls on the page, but there are no current validation errors.
However, even though I'm not returning false
from the JavaScript the page isn't posting back. I've even attempted to return true;
but that didn't change anything (not really that surprising but it was worth a try).
I look forward to your feedback!
Share Improve this question edited Jan 7, 2013 at 12:30 Mike Perrenoud asked Jan 7, 2013 at 12:23 Mike PerrenoudMike Perrenoud 68k32 gold badges166 silver badges238 bronze badges 3-
The
CausesValidation="true"
? Do you have ValidationControls on your page? Those could cause it – codingbiz Commented Jan 7, 2013 at 12:26 - @codingbiz, I do have validation controls on the page, but there are no validation errors. – Mike Perrenoud Commented Jan 7, 2013 at 12:29
-
This can also occur if you remove the control or the parent control of the control that you are posting back with, something like
OnClientClick="$(this).remove()"
will cause the same issue. – David Rogers Commented Jun 2, 2016 at 14:05
2 Answers
Reset to default 8It seems like you are disabling your button, before the postback.
You could try your page/script without the disabling part in it:
OnClientClick="$('#SearchingLabel').show();"
If this works, try it with a short delay:
OnClientClick="setTimeout(function() { $('#Find').attr('disabled', 'disabled'); }, 100); $('#SearchingLabel').show();"
Try this js code onload
Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequest);
Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequest);
function BeginRequest(sender, e) {
e.get_postBackElement().disabled = true;
// or your code
}
function EndRequest(sender, e) {
.......
}