The*_*oot 19 javascript asp.net scriptmanager
我过去曾使用这样的代码在我的asp.net网页上成功弹出警报消息.现在它不起作用.我无法弄清楚为什么.
ScriptManager.RegisterStartupScript(this, typeof(Page), UniqueID,
"alert('This pops up')", true);
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
Fré*_*idi 41
脱离我的头顶:
GetType()而不是typeof(Page)为了将脚本绑定到您的实际页面类而不是基类,Page.UniqueID不是,因为它应该被命名控件使用,所以没有那么有意义,PreRender阶段注册脚本:protected void Page_PreRender(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, GetType(), "YourUniqueScriptKey",
"alert('This pops up');", true);
}
Run Code Online (Sandbox Code Playgroud)
小智 19
试试这个代码......
ScriptManager.RegisterClientScriptBlock(UpdatePanel1, this.GetType(), "script", "alert('Hi');", true);
Run Code Online (Sandbox Code Playgroud)
您页面上UpdatePanel1的idfor Updatepanel在哪里
| 归档时间: |
|
| 查看次数: |
126246 次 |
| 最近记录: |