由于直接用的是asp.net自带的ajax 所以弹出框用了->ScriptManager.RegisterStartupScript的方法,
代码如下
ScriptManager.RegisterStartupScript(this.btn_Save, this.btn_Save.GetType(), "唯一标识符1", "alert('" + "添加成功!" + "')", true);Response.Redirect("~/XXX/AAA.aspx");
现在出现的问题是 弹出框没有显示就跳转到AAA.aspx了,我希望弹出框出来后用户确认后再跳转PS:注释掉最后一行,弹出框是可以弹出来了。
代码如下
ScriptManager.RegisterStartupScript(this.btn_Save, this.btn_Save.GetType(), "唯一标识符1", "alert('" + "添加成功!" + "')", true);Response.Redirect("~/XXX/AAA.aspx");
现在出现的问题是 弹出框没有显示就跳转到AAA.aspx了,我希望弹出框出来后用户确认后再跳转PS:注释掉最后一行,弹出框是可以弹出来了。
Response.Write("<script language='javascript'>");
Response.Write("alert('xxx!');");
Response.Write("document.location.href=xxx.aspx'");
Response.Write("</script>");
不是可以在这里跳用一个js函数么...然后做跳转操作
Response.Write("<script>alert('添加成功!');window.location.href ='Index.aspx'</script>");
Page.PreviousPage.RegisterStartupScript("script", "<script>alert('添加成功!');window.location.href='~/XXX/AAA.aspx'</script>");
Page.ClientScript.RegisterStartupScript(this.GetType(), "script", "<script>alert('添加成功!');window.location.href='~/XXX/AAA.aspx'</script>",true);
Response.Write("<script>alert('添加成功!');window.location.href='~/XXX/AAA.aspx'</script>");
注: 当用户选择的是[否]时 Button4_Click()里的代码不会执行的
会破坏页面结构。。你这个要跳转倒是无所谓
不过有时候不会跳转,就不好了
建议ScriptManager