2016-11-08 32 views
0

我看到很多關於使用AJAX調用將數據從jQuery發佈到ASP.NET頁面的信息,但沒有其他辦法。如何從ASP.NET頁面發佈數據到jQuery?

如何從ASP.NET頁面調用jQuery方法?

+1

的可能的複製[如何調用從C#jQuery函數(http://stackoverflow.com/questions/22216177/how-to-call-jquery-function-from-c-sharp) – Andrea

回答

0
$.ajax({ 
     type: "POST", 
     url: 'ControllerName/FunctionName', 
     data: '{mydate: "' + $("#mydata").val() + '" }', 
     contentType: "application/json; charset=utf-8", 
     dataType: "json", 
     success: function (data) { 
      alert(data); 

      }) 
     } 
    }); 
1

我想你想從服務器端調用jquery,這裏是從c#調用jquery的一個例子。

ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "script", "postfunction();", true); 
相關問題