在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
C#前台js调用后台代码 前台js
<script type="text/javascript" language="javascript"> function Ceshi() { var a = "<%=Getstr()%>"; alert(a); }</script><input type="button" onclick="Ceshi();" value="js调用后台代码" /> 后台代码
public string Getstr(){ string aa = "你们好啊!"; return aa;} C#后台调用前台js代码 前台js
<script type="text/javascript" language="javascript"> function Ceshi() { var a = "你们好啊!" alert(a); }</script><asp:Button ID="Button1" runat="server" Text="后台调用js" onclick="Button1_Click" /> 后台代码
protected void Button1_Click(object sender, EventArgs e) { //如果有UpdatePanel就用如下代码调用前台js ScriptManager.RegisterStartupScript(UpdatePanel1, this.Page.GetType(), "", "Ceshi();", true); //如果没有就如下代码 this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "", "<script>Ceshi();</script>", true); }
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论