且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用ClientScript.RegisterClientScriptBlock与在线code?

更新时间:2023-12-05 23:16:28

您需要通过真正作为最后一个参数的的RegisterClientScriptBlock()为了让您的客户端code被包裹在一个 <脚本> 元素:

You need to pass true as the last argument to RegisterClientScriptBlock() in order for your client-side code to be wrapped in a <script> element:

protected void Page_Load(object sender, EventArgs e)
{
    ClientScript.RegisterClientScriptBlock(GetType(), "Email",
        "GetEmail();", true);
}