[英]How to call Server side Public method in Javascript
我使用以下方式致電:
使用頁面方法
1)
function callBackMiscQuoteItems(val) {
PageMethods.FillTowingMiscItemsGrid();
}
[WebMethod]
public static void BindControls() {
}
2) <% BindControls(); %>
<% BindControls(); %>
但是這兩個程序不起作用
有人在那里幫我..
我們可以使用JQuery進行調用還是任何其他方式?
asp.net從Javascript異步調用WebMethod-看看這篇文章。
關於您的代碼。 您的網絡方法稱為BindControls
,如果它不僅是一個示例,而是在調用PageMethods.FillTowingMiscItemsGrid()
而不是PageMethods.BindControls()
。 另一個可能的問題: PageMethods.FillTowingMiscItemsGrid()
此調用不會在客戶端執行任何操作。 您必須指定成功回調函數才能在客戶端執行某些操作:
PageMethods.FillTowingMiscItemsGrid(function(response) {//do something})
另外,類似<% BindControls(); %>
代碼<% BindControls(); %>
<% BindControls(); %>
是在服務器上執行的,默認情況下不會生成JS調用。
這是有關如何使用網絡方法的小教程。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.