1、常用信息提示方法类
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Web; using System.Data; using System.Web.SessionState; namespace ECS.Utility { public class JScript { protected static HttpResponse Response; protected static HttpSessionState Session; public JScript() { // // TODO: 在此处添加构造函数逻辑 // } /// <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">注册的脚本</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 ShowRefresh(System.Web.UI.Page page, string msg) { page.ClientScript.RegisterStartupScript(page.GetType(), "msg", "<script>location.reload();alert('" + msg + "。');</script>"); } /// <summary> /// 刷新页面并且弹出提示信息并注册脚本 /// </summary> /// <param name="page">this</param> /// <param name="msg">提示信息</param> public static void ShowRefresh(System.Web.UI.Page page, string msg, string script) { page.ClientScript.RegisterStartupScript(page.GetType(), "msg", "<script>location.reload();" + 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">注册脚本</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>"); } /// <summary> /// 注册脚本 /// </summary> /// <param name="page">this</param> /// <param name="script">注册的脚本</param> public static void ShowRegisterScript(System.Web.UI.Page page, string script) { page.ClientScript.RegisterStartupScript(page.GetType(), "msg", "<script>" + script + "</script>"); } /// <summary> /// 弹出JavaScript小窗口 /// </summary> /// <param name="js">窗口信息</param> public static void Alert(string message) { message = StringUtil.DeleteUnVisibleChar(message); string js = @"<Script language='JavaScript'> alert('" + message + "');</Script>"; HttpContext.Current.Response.Write(js); } /// <summary> /// 弹出JavaScript小窗口,并转向指定的页面 /// </summary> /// <param name="message">弹出信息</param> /// <param name="toURL">专转向的网页</param> public static void AlertAndRedirect(string message, string toURL) { string js = "<script language=javascript>alert('{0}');window.location.replace('{1}')</script>"; HttpContext.Current.Response.Write(string.Format(js, message, toURL)); } public static void Redirect(string toURL) { string js = "<script language=javascript>window.location.replace('{0}')</script>"; HttpContext.Current.Response.Write(string.Format(js, toURL)); } /// <summary> /// 函数名:GotoParentWindow /// 功能描述:返回父窗口 /// 处理流程: /// 算法描述: /// 作 者: /// 日 期: 2003-04-30 10:00 /// 修 改: /// 日 期: /// 版 本: /// </summary> /// <param name="parentWindowUrl">父窗口</param> public static void GotoParentWindow(string parentWindowUrl, string Msg) { string js = @"<Script language='JavaScript'> this.parent.location.replace('../" + parentWindowUrl + "');" + Msg + "</Script>"; HttpContext.Current.Response.Write(js); } /// <summary> /// 刷新窗口 /// </summary> public static void Refresh() { string js = @"<Script language='JavaScript'> window.location.href=window.location.href; </Script>"; HttpContext.Current.Response.Write(js); } } }
2、页面权限校验
/// <summary> /// 判断权限 /// </summary> /// <param name="DisplayName">权限名称</param> public static void MyRole(string DisplayName) { bool bfg = false; IYUEJIE.Model.A_AdminUser AdminUserModel = HttpContext.Current.Session["AdminUser"] as IYUEJIE.Model.A_AdminUser;//得到登录LoginId DataTable dt = new DBHelper().GetDataSet("SELECT * FROM View_SysRoleList where RoleID='" + AdminUserModel.RoleId + "' and [Custom
时间: 2024-10-26 16:11:24