如何实现?点一个控件后出现提示信息“您不是管理员请先登录”,按确定后,自动跳转到管理员登陆页面

来源:百度知道 编辑:UC知道 时间:2024/05/25 09:11:53
补充一下:
Response.Write("<script>alert('对不起只有管理员才能恢复,请先登录!');</script>");
Response.Redirect("login.aspx");
这样好像不对...有什么好的方法?
一楼的问一下,按你的写上去,他有提示错误啊...要怎么改啊
错误 1 应输入 ) D:\My Documents\Visual Studio 2008\Projects\MessageBoard\Default.aspx.cs 129 87 D:\...\MessageBoard\
错误 2 应输入 ; D:\My Documents\Visual Studio 2008\Projects\MessageBoard\Default.aspx.cs 129 97 D:\...\MessageBoard\
错误 3 应输入 ; D:\My Documents\Visual Studio 2008\Projects\MessageBoard\Default.aspx.cs 129 109 D:\...\MessageBoard\
错误 4 无效的表达式项“)” D:\My Documents\Visual Studio 2008\Projects\MessageBoard\Default.aspx.cs 129 109 D:\...\MessageBoard\

你的问题是 Response.Write 与 Response.Redirect 不一定像你预期的那样顺序执行,可能 Response.Redirect 在 Response.Write 前执行了即 跳转了但是没有提示, 还有可能是提示了不跳转。

把 跳转 做到 脚本里面,
("<script>alert('对不起只有管理员才能恢复,请先登录!');</script>");
在 【先登录!'); 】 这里加 脚本跳转语句 就可以了。

window.location.href="Login.aspx";


Response.Write("<script>alert('对不起只有管理员才能恢复,请先登录!');window.location.href="Login.aspx";</script>");

asp.net要转义
用一个Button测试通过
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("<script>alert('对不起只有管理员才能恢复,请先登录!') ;window.location.href=\"http://zhidao.baidu.com/question/119825763.html?ansup1\";</script>");
}
你改为:
Response.Write("<script>alert(