【发布时间】:2016-10-18 22:02:44
【问题描述】:
我想使用 JavaScript 显示不同的警报消息。这是我的代码,但我的警告框不会在重定向之前显示。我尝试了提供的其他示例,但这些示例都只使用一种类型的警报消息。我也使用此 ShowAlertMessage 方法来显示其他类型的警告,其中我不想重定向到任何其他页面。只需给用户一个警告。
If (user creates a new work order)
{
ShowAlertMessage("Property work order " + txtWorkOrderNumber.Text + " created successfully");
}
else
ShowAlertMessage("Property work order updated successfully");
Response.Redirect("~/DashBoard.aspx");
public static void ShowAlertMessage(string msg)
{
Page page = HttpContext.Current.Handler as Page;
if (page != null)
{
string script = "alert(\"'" + msg + "'\");";
ScriptManager.RegisterStartupScript(page, page.GetType(), "err_msg", script, true);
}
}
【问题讨论】:
标签: javascript c# asp.net redirect alert