4

我有一组 ASP.NET 控件:

<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;" />

正如您所看到的,我正在使用,OnClientClick以便我可以禁用Find按钮并显示SearchingLabel并且 JavaScript 可以正常工作,顺便说一句)。很基本的东西。

此外,围绕CausesValidation属性,我在页面上确实有验证控件,但没有当前的验证错误。

但是,即使我没有false从 JavaScript 返回页面也没有回发。我什至尝试过,return true;但这并没有改变任何东西(并不那么令人惊讶,但值得一试)。

我期待您的反馈!

4

2 回答 2

8

在回发之前,您似乎正在禁用您的按钮。

您可以在没有禁用部分的情况下尝试您的页面/脚本:

OnClientClick="$('#SearchingLabel').show();"

如果这可行,请稍等片刻尝试:

OnClientClick="setTimeout(function() { $('#Find').attr('disabled', 'disabled'); }, 100); $('#SearchingLabel').show();"
于 2013-01-07T12:32:42.613 回答
0

试试这个js代码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) {
   .......
}
于 2013-01-07T12:49:41.883 回答