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