相关疑难解决方法(0)

如何将ClientScript.RegisterClientScriptBlock与内联代码一起使用?

我有aspx页面,后面没有代码.服务器端使用runat服务器属性在标签内编写的代码.

如果我使用

ClientScript.RegisterClientScriptBlock(this.GetType(), "Email", "GetEmail();");
Run Code Online (Sandbox Code Playgroud)

在page_load()事件中,它只是GetEmail();在页面加载时打印

我的代码看起来像

<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <script type="text/javascript" language="javascript">
            function GetEmail()
            {
                alert('hi');
            }
        </script>

    </head>
    <body>
    <form id="form1" runat="server">
           Some control here
    </form>
</body>
</html>

<script runat="server">
    protected void Page_Load(object sender, EventArgs e)
    {
ClientScript.RegisterClientScriptBlock(this.GetType(), "Email", "GetEmail();");
}
</script>
Run Code Online (Sandbox Code Playgroud)

提前致谢.

asp.net

2
推荐指数
1
解决办法
2万
查看次数

标签 统计

asp.net ×1