1

我一直在阅读一些主题,StackOverFlow并找到了一些刷新页面的方法,例如:
Response.Redirect(Request.RawURL);, Response.Redirect(Absolute.Uri) etc...

但我需要发送确认警报并刷新页面......现在,我正在使用此方法发送警报:

ScriptManager.RegisterStartupScript(this, typeof(Page), "alert", "alert('Well Done !');", true);  

但是使用这些方法中的任何一种来刷新页面,都不会触发警报。所以我需要知道一种很好的方法来做到这一点。
因为我有一些DropDownList数据来自database并且我正在Edits对数据进行一些处理,所以当用户单击edit当前数据的按钮时,它会显示一条消息,edit successfully然后用新数据刷新页面。

4

2 回答 2

2

客户端重定向怎么样?

alert("You're now will be redirected");
window.location.reload();

由于 alert() 是同步函数,重定向只会在用户点击“ok”时触发

于 2013-03-25T13:20:31.913 回答
0

上面的客户端脚本可以通过这种方式添加到您的代码隐藏中。

protected void Render()
{
    System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder("<script "
        + "type='text/javascript'>"
        );
    stringBuilder.Append("alert('hi');");
    stringBuilder.Append("window.location.reload();");
    stringBuilder.Append("</script>");

}
于 2013-03-25T13:31:03.347 回答