RegisterStartupScript在C#中不起作用

时间:2018-11-16 04:04:11

标签: javascript c# asp.net

J在C#上的ClientScript.RegisterStartupScript有问题。我的代码不起作用 我有ASP.NET:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
        <div>
        </div>
    </form>
</body>
    <script>
        function Test() {
            alert("a");
        }
    </script>
</html>

后面的代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Test
{
    public partial class Test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            ClientScript.RegisterStartupScript(GetType(), "Test1", "Test();", true);
        }
    }
}

我尝试过 ScriptManager.RegisterStartupScriptClientScript.RegisterClientScriptBlock 但他们没用

请帮助我:(谢谢

0 个答案:

没有答案