弹出提示框的几种基本方式:
Response.Write("<script>alert('成功!');window.location.href='task.aspx';</script>");
在ajax中上述方式将失效,解决办法如下:
ScriptManager.RegisterStartupScript(this,this.GetType(),"test","alert('成功!');",true);
Response.Write("<script>alert('成功!');window.location.href='task.aspx';</script>");
Page.ClientScript.RegisterStartupScript(this.GetType(), "test", "<script>alert('成功!');</script>");
Page.RegisterStartupScript("test", "<script>alert('成功!');</script>");
在ajax中上述方式将失效,解决办法如下:
ScriptManager.RegisterStartupScript(this,this.GetType(),"test","alert('成功!');",true);
ps:最后一个参数的bool值表示是否在前一个参数script中加<script></script>标签,当为false时需要手动加该标签