没登陆的用户访问某个要登录的页面,自动跳转到登录页面,中间弹出一个alert,怎么弄
答案:4 悬赏:0 手机版
解决时间 2021-01-23 14:37
- 提问者网友:献世佛
- 2021-01-23 01:16
if (Session["adminname"] == null) { Response.Write("<script>alert('请选登录')</script>"); Response.Redirect("admin_login.aspx"); }这样好像不行
最佳答案
- 五星知识达人网友:舍身薄凉客
- 2021-01-23 01:49
使用了 Response.Redirect 后,任何 Write 都不会起作用,请使用 js 方法
if (Session["adminname"] == null)
{
Response.Write("<script>alert('请选登录');location.href='admin_login.aspx';</script>");
}
该方法不能用于在 UpdatePanel 中发生的事件回发中,如果要在其中使用,请参考 ClientScriptManager
if (Session["adminname"] == null)
{
Response.Write("<script>alert('请选登录');location.href='admin_login.aspx';</script>");
}
该方法不能用于在 UpdatePanel 中发生的事件回发中,如果要在其中使用,请参考 ClientScriptManager
全部回答
- 1楼网友:想偏头吻你
- 2021-01-23 03:36
if (Session["adminname"],ToString() == null)
{
Response.Write("alert('请选登录');");
Response.Redirect("admin_login.aspx");
}
- 2楼网友:旧脸谱
- 2021-01-23 03:16
使用了 response.redirect 后,任何 write 都不会起作用,请使用 js 方法
if (session["adminname"] == null)
{
response.write("<script>alert('请选登录');location.href='admin_login.aspx';</script>");
}
该方法不能用于在 updatepanel 中发生的事件回发中,如果要在其中使用,请参考 clientscriptmanager
- 3楼网友:罪歌
- 2021-01-23 02:56
把那个判断改成这样试试:
if (Session["adminname"] == "")
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯