我使用下面的代码btn
Click
事件中:无法注册启动脚本
ClientScript.RegisterStartupScript(typeof(Page), "exampleScript", "alert('you just registered the start up script');", true);
脚本被注册的<body>
内,我没有得到任何警告。
如何注册启动脚本并获取此警报消息?如果要执行上按一下按钮脚本则不要使用ClientScript.RegisterStartupScript()
我会建议你使用ClientScript.RegisterClientScriptBlock()
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "myKey", "alert('you just registered the start up script');", true);
您是否尝试在函数调用中添加括号?例如,而不是“exampleScript”,请尝试“exampleScript()”。 – 2012-02-08 16:53:18
这就是“脚本键”,而不是函数名。它只是使用该密钥将脚本注册到registerstartupscript – 2012-02-08 16:54:51
您是否尝试从更新面板中注册启动脚本? – 2012-02-08 16:58:07