在所有页面按钮的母版页中:
findButton.Attributes.Add( "onclick", @" $(""#" + findButton.ClientID + @""").val(""Processing..."").attr(""disabled"",""disabled"");" + Page.ClientScript.GetPostBackEventReference( findButton, null ) + ";" );
该页面包含:
<script type="text/javascript">
function BindEvents() {
$(document).ready(function () {
... prepare jquery ui combo boxes ...
});
}
</script>
<asp:UpdatePanel runat="server" ID="UpdatePanel">
<Triggers>
<asp:PostBackTrigger ControlID="btnPrint" />
</Triggers>
<ContentTemplate>
<script type="text/javascript">Sys.Application.add_load(BindEvents);</script>
<asp:Panel ID="pnlMainButtons" runat="server" Visible="true">
<table>
<tr>
<td>
<asp:Button ID="btnFind" runat="server" Text="Find" OnClick="btnFind_OnClick" />
</td>
<td>
<asp:Button ID="btnPrint" runat="server" Text="Print" OnClick="btnPrint_OnClick" />
</td>
</tr>
</table>
</asp:Panel>
... other user controls ...
</ContentTemplate>
</asp:UpdatePanel>
并且没有设置AutoPostBack。查找按钮呈现为:
<input id="ctl00_ctl00_MainPlaceHolder_PlaceHolder_btnFind" type="submit" onclick=" $("#ctl00_ctl00_MainPlaceHolder_PlaceHolder_btnFind").val("Processing...").attr("disabled","disabled");__doPostBack('ctl00$ctl00$MainPlaceHolder$PlaceHolder$btnFind','');" value="Find" name="ctl00$ctl00$MainPlaceHolder$PlaceHolder$btnFind">
Firefox中的Firebug通过单击“查找”按钮显示双重请求发送 - 第二个请求成功,但是什么原因导致第一个请求被发送?