2015-10-14 36 views

回答

1

您可以在代碼中使用以下jQuery腳本在beginRequest中調用您的函數。你必須將這些控件的的AutoPostBack財產您要回調函數調用之前啓動這一

<script type="text/javascript"> 
jQuery(function ($) { 
    var prm = Sys.WebForms.PageRequestManager.getInstance(); 
    prm.add_beginRequest(function (source, args) { 
     // YOUR FUNCTION CALL HERE such as display processing/loading prompt/div 
    }); 
    prm.add_endRequest(function (source, args) { 
     // any other code you want to execute after the post back finishes such as hiding processing/loading prompt/div 
    }); 
}); 
</script> 

一定要一個的ScriptManager和UpdatePanel的添加到您的頁面設置爲true。欲瞭解更多詳情可查看該MSDN reference

0

您可以使用下面的代碼

$(document).ready(function() { 
    $("form").submit(function() { 
     // do the extra stuff here 
     //return true to submit the form 
     //return false if do not want to submit form 
    }); 
}); 
+0

你不覺得$(「form」)。submit(function()'只會在我們點擊表單上的提交按鈕而不是其他按鈕時運行 – haraman

0

實例調用服務器端的一個jQuery函數Page_Load事件的:

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 
'"Expandir Compras" its the Unique identifier of the script code 
    ScriptManager.RegisterStartupScript(Me, [GetType](), "Expandir Compras", "$('#collapseCompras').collapse('show');", True) 
End Sub 

也許你可以做些什麼類似於正確的事件(保存更改,預加載,數據綁定等)。希望能幫助到你!