.net 后台调用前台js方法

aspx:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript">
function a() {
alert(
"ceshi");
}
</script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
    </div>
    </form>
</body>
</html>

aspx.cs:

protected void Button1_Click(object sender, EventArgs e)
{
ClientScript.RegisterStartupScript(ClientScript.GetType(),
"a", "<script>a();</script>");
}

 

posted @ 2020-08-28 10:57  tommy~hi  阅读(270)  评论(0编辑  收藏  举报