- using System;
- using System.Data;
- using System.Configuration;
- using System.Web;
- using System.Web.Security;
- using System.Web.UI;
- using System.Web.UI.WebControls;
- using System.Web.UI.WebControls.WebParts;
- using System.Web.UI.HtmlControls;
- /// <summary>
- /// AdminPageBase 的摘要说明
- /// </summary>
- public class AdminPageBase : System.Web.UI.Page
- {
- public AdminPageBase()
- {
- //
- // TODO: 在此处添加构造函数逻辑
- //
- }
- protected override void OnInit(EventArgs e)
- {
- base.OnInit(e);
- this.Load += new EventHandler(Page_Load);
- }
- protected void Page_Load(object sender, EventArgs e)
- {
- string sUserID = Session["UserID"];
- string sRole = Session["Role"];
- if(sUserID == "")
- {
- WriteScript("window.alert('未登录不能操作后台管理功能!');window.top.location.href='/member/login.aspx';");
- return;
- }
- if(sRole != "Administrator")
- {
- WriteScript("window.alert('你不是管理员,不能进入后台!');window.top.location.href='/member/login.aspx';");
- return;
- }
- }
- /// <summary>
- /// 向客户端写入脚本块
- /// </summary>
- /// <param name="sScript">脚本块代码(不包含script标记)</param>
- public void WriteScript(string sScript)
- {
- string sOut = String.Format("<script language='javascript'>{0}</script>", sScript);
- this.RegisterClientScriptBlock("myscript", sOut);
- }
- /// <summary>
- /// 向客户端页面弹出消息框
- /// </summary>
- /// <param name="sMsg">消息内容</param>
- public void MsgBox(string sMsg)
- {
- string sScript = String.Format("window.alert('{0}');", sMsg.Replace("'", "//'"));
- WriteScript(sScript);
- }
- /// <summary>
- /// 提示信息并自动跳转页面
- /// </summary>
- /// <param name="sMsg">提示的信息内容</param>
- /// <param name="sPage">需要跳转的页面URL</param>
- public void MsgAndTransfer(string sMsg, string sPage)
- {
- string sScript = String.Format("window.alert('{0}');window.location.href='{1}';", sMsg, sPage);
- WriteScript(sScript);
- }
- }
用户信息验证基类
最新推荐文章于 2022-04-11 22:47:09 发布