PageBase 公共基础类
using System; using System.Collections.Generic; using System.Linq; using System.Web; /// <summary> /// PageBase 公共基础类 /// </summary> public class PageBase : System.Web.UI.Page { #region 重新System.Web.UI.Page基类方法 //重写基类中的抽象方法init override protected void OnInit(EventArgs e) { Page.Response.Expires = -1; base.OnInit(e); this.InitEventHandler(); //判断是否登录 if (HttpContext.Current.Session["AdminUser"] == null) { string SysFoder = Common.SysFoder; HttpContext.Current.Response.Redirect("~/" + SysFoder + "/login.aspx"); } } #endregion #region 公用属性 /// <summary> /// 管理人员登录用户ID /// </summary> private int loginID; /// <summary> /// 管理人员登录用户ID /// </summary> public int LoginID { get { return Common.LoginID(); } set { loginID = value; } } /// <summary> /// 管理人员登录用户名 /// </summary> private string loginName; /// <summary> /// 管理人员登录用户名 /// </summary> public string LoginName { get { return Common.LoginName(); } set { loginName = value; } } /// <summary> /// 登录用户类型 /// </summary> private int loginType; /// <summary> /// 登录用户类型 /// </summary> public int LoginType { get { return this.GetLoginType(); } set { loginType = value; } } /// <summary> /// 得到用户登录类型 /// </summary> /// <returns></returns> public int GetLoginType() { if (Session["LoginType"] != null) { return Session["LoginType"].ToString().ToInt(0); } return 0; } #endregion #region javascript脚本注册提示 /// <summary> /// 信息提示 /// </summary> /// <param name="page">this</param> /// <param name="msg">提示信息</param> public static void ShowAlert(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "msg", "<script>alert('" + msg + "');</script>"); } /// <summary> /// 信息提示 /// </summary> /// <param name="page">this</param> /// <param name="msg">提示信息</param> /// <param name="script">script</param> public static void ShowAlert(System.Web.UI.Page page, string msg, string script) { page.ClientScript.RegisterStartupScript(page.GetType(), "msg", "<script>alert('" + msg + "');" + script + "</script>"); } /// <summary> /// 刷新父页面并且弹出提示信息 /// </summary> /// <param name="page">this</param> /// <param name="msg">提示信息</param> public static void ShowParentRefresh(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "msg", "<script>parent.location.reload();alert('" + msg + "。');</script>"); } /// <summary> /// 刷新后执行脚本 /// </summary> /// <param name="page">this</param> /// <param name="msg">提示信息</param> /// <param name="script">script</param> public static void ShowParentRefresh(System.Web.UI.Page page, string msg, string script) { page.ClientScript.RegisterStartupScript(page.GetType(), "msg", "<script>parent.location.reload();alert('" + msg + "。');" + script + "</script>"); } #endregion virtual protected void InitEventHandler() { } }
时间: 2024-10-27 18:15:22