後臺調用前臺js方法:javascript
this.Page.ClientScript.RegisterStartupScript(this.GetType(), "js", "ShowMaterialManager('" + url + "');", true);
後臺注入JQuery語句:java
page.RegisterStartupScript(Guid.NewGuid().ToString(), string.Format("<script language=javascript>{0}</script>", script));
前臺調用後臺的方法:ui
C#後臺代碼:this
1 public string GetUserName() 2 { 3 string userName= "小明"; 4 return userName; 5 }
JQuery前臺代碼調用:url
<script type="text/javascript"> $(document).ready(function () { $(function Show() { alert("<%= GetUserName() %>"); }); }); </script >