这是一个场景,我有按钮,当用户点击它时,应该首先检查数据库,如果它为空,客户端脚本将出现,如果用户单击ok,会话将结束,但我的代码不起作用。有人能帮上忙吗?谢谢!
protected void btnLogout_Click(object sender, EventArgs e)
{
if (logout.checkLogoutGuest(""))
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "ScriptKey", "alert('There guest that didn't logged out.');window.location='Login.aspx'; ", true);
int id = logout.selectLogin();
logout.updateLogin(id, DateTime.Now.ToString());
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoServerCaching();
HttpContext.Current.Response.Cache.SetNoStore();
}
else{
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.Cache.SetNoServerCaching();
HttpContext.Current.Response.Cache.SetNoStore();
Session.Abandon();
int id = logout.selectLogin();
logout.updateLogin(id, DateTime.Now.ToString());
Response.Redirect("Login.aspx", false);
}
}发布于 2017-08-03 13:04:27
检查您的重定向页面路径和浏览器控制台是否有任何其他错误。
ScriptManager.RegisterClientScriptBlock(this.GetType(),
"ScriptKey", "alert('There guest that didn't logged out.');window.location = '/absolutepath'", true);https://stackoverflow.com/questions/45474032
复制相似问题