RegisterClientScriptBlock不起作用

时间:2017-08-03 02:55:31

标签: javascript c# asp.net

这是方案,我有按钮,当用户点击它时应首先检查数据库然后如果它为null将显示clientscript,如果用户单击确定会话将结束但我的代码不起作用。有人可以帮忙吗?谢谢!

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);

    }    

}

1 个答案:

答案 0 :(得分:0)

Check your redirecting page path and also browser console for any other errors.

rails d model student