[英]Show alert message before redirecting to other page ASP.NET
I have found a lot of examples but I don't know why these are not working for me. 我发现了很多示例,但我不知道为什么这些示例对我不起作用。 I have tried these but in vain. 我尝试了这些但徒劳。
I have also tried the following: 我也尝试了以下方法:
String message = "Session Expired! Log In Again.";
ClientScript.RegisterStartupScript(
this.GetType(),
Guid.NewGuid().ToString(),
string.Format("alert('{0}');window.location.href = 'default.aspx'",
message.Replace("'", @"\'").Replace("\n", "\\n").Replace("\r", "\\r")),
true);
and 和
ScriptManager.RegisterStartupScript(
this,
this.GetType(),
"redirect",
"alert('Session Expired! Log In Again.');
window.location='" + Request.ApplicationPath + "Account/login.aspx';",
true);
and 和
Response.Write("
<script language='javascript'>
window.alert('Session Expired');
window.location='~/Account/Login.aspx';
</script>");
but all of these are not redirecting to the login page just showing the alert message. 但所有这些都不会重定向到登录页面,仅显示警告消息。
try this 尝试这个
window.location.href="Account/Login.aspx";
remove ~ operator from the path 从路径中删除〜运算符
Try this 尝试这个
Response.Write("<script language='javascript'>window.alert('Popup message ');window.location='webform.aspx';</script>");
Change location and message. 更改位置和消息。
Happy coding Regards, AK. 祝您编码愉快,AK。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.