首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >RegisterClientScriptBlock不工作

RegisterClientScriptBlock不工作
EN

Stack Overflow用户
提问于 2017-08-03 10:55:31
回答 1查看 33关注 0票数 0

这是一个场景,我有按钮,当用户点击它时,应该首先检查数据库,如果它为空,客户端脚本将出现,如果用户单击ok,会话将结束,但我的代码不起作用。有人能帮上忙吗?谢谢!

代码语言:javascript
复制
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);

    }    

}
EN

回答 1

Stack Overflow用户

发布于 2017-08-03 13:04:27

检查您的重定向页面路径和浏览器控制台是否有任何其他错误。

代码语言:javascript
复制
 ScriptManager.RegisterClientScriptBlock(this.GetType(),
    "ScriptKey", "alert('There guest that didn't logged out.');window.location = '/absolutepath'", true);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45474032

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档