use*_*399 5 c# asp.net registerstartupscript
我在OnInit hanlder中有一些代码
if (!Page.ClientScript.IsStartupScriptRegistered(GetType(), "MyScript"))
{
Page.ClientScript.RegisterStartupScript(GetType(), "MyScript", GetStartupScript(), true);
}
Run Code Online (Sandbox Code Playgroud)
在这里我尝试注册一些Java脚本代码.我想让它在按钮点击事件上工作.但它没有执行.它仅在刷新页面后执行.谁能解释我为什么不执行?
thnx提前!
小智 12
试试这个:
ScriptManager.RegisterStartupScript(this, typeof(string), "Error",
"alert('hi');", true);
Run Code Online (Sandbox Code Playgroud)