可在服務器端加載方法:
復制代碼 代碼如下:
private void OnLoading()
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
sb.Append(" function pageLoad(){var manager = Sys.WebForms.PageRequestManager.getInstance(); ");
sb.Append(" manager.add_beginRequest(OnBeginRequest); manager.add_endRequest(OnEndRequest)} var lcPostbackElementID;");
sb.Append(" function OnBeginRequest(sender, args){ lcPostbackElementID = args.get_postBackElement().id.toLowerCase(); if (lcPostbackElementID === \"btnadwords\"){$get(\"btnAdWords\").disabled = true; $get(\"btnAdWords\").value='正在提交...';}} ");
sb.Append(" function OnEndRequest(sender, args){if (lcPostbackElementID === \"btnadwords\"){ $get(\"btnAdWords\").disabled = false; $get(\"btnAdWords\").value='確定';}} ");
ScriptManager.RegisterStartupScript(Page, Page.GetType(), "btnAdWords", sb.ToString(), true);
}
也可直接寫在頁面腳本里:
復制代碼 代碼如下:
script>
function pageLoad()
{
var manager = Sys.WebForms.PageRequestManager.getInstance();
manager.add_beginRequest(OnBeginRequest);
manager.add_endRequest(OnEndRequest)
}
var lcPostbackElementID;
function OnBeginRequest(sender, args)
{
lcPostbackElementID = args.get_postBackElement().id.toLowerCase();
if (lcPostbackElementID === 'btnadwords')
{
$get('btnAdWords').disabled = true;
$get('btnAdWords').value='正在提交...';
}
}
function OnEndRequest(sender, args)
{
if (lcPostbackElementID === \"btnadwords\")
{
$get('btnAdWords').disabled = false;
$get('btnAdWords').value='確定';
}
}
/script>
更多內容請參考:http://msdn.microsoft.com/zh-cn/magazine/cc163319.aspx
您可能感興趣的文章:- 防止ajax重復請求的方法(GET和POST)
- AJAX避免用戶重復提交請求實現方案
- AJAX提交表單數據實例分析
- 防止重復發(fā)送Ajax請求的解決方案
- PHP中如何防止外部惡意提交調用ajax接口