在ASP.NET中重定向之前的Javascript警报

Roh*_*ari 11 javascript c# asp.net ajax updatepanel

我在更新面板中更新时使用以下代码显示消息

string jv = "alert('Time OutAlert');";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", jv, true);
Run Code Online (Sandbox Code Playgroud)

它工作正常.

但是当我在它之后使用Redirect时它会加载页面而不显示消息.我希望用户看到该消息,点击"确定"后,它应该重定向.

string jv = "alert('Time OutAlert');";
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "msg", jv, true);
Response.Redirect("~/Nextpage.aspx");
Run Code Online (Sandbox Code Playgroud)

Vis*_*har 27

使用javascript显示警报,然后使用相同的重定向:

ScriptManager.RegisterStartupScript(this,this.GetType(),"redirect",
"alert('Time OutAlert'); window.location='" + 
Request.ApplicationPath + "Nextpage.aspx';",true);
Run Code Online (Sandbox Code Playgroud)