- 浏览: 251636 次
- 性别:
- 来自: 北京
文章分类
最新评论
-
u010181690:
怎么我的不管事呢
JSEnhancements for vs2012 -
sunqing0316:
public static DateTime? GetData ...
详解System.Nullable<值类型> -
sunqing0316:
请问public static DateTime? GetDa ...
详解System.Nullable<值类型> -
3eirc3:
不错,下载下来试试,原来用vs2010时的那个工具和现在这个不 ...
JSEnhancements for vs2012 -
3eirc3:
[url][b][i][u]引用[list]
[*][img] ...
JSEnhancements for vs2012
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Web.UI.WebControls;
using MCS.WDEDUCloud.Common.DataModel;
using MCS.WDEDUCloud.Common.Business.OP;
using MCS.WDEDUCloud.Common.Utility;
namespace MCS.WDEDUCloud.Portal.OP.Base
{
public class BasePage : System.Web.UI.Page
{
#region UserInfo
ERoleBLL RoleBll;
private EUserInfo currentuser = null;
/// <summary>
/// 当前登录人
/// </summary>
public EUserInfo CurrentUser
{
get
{
if (currentuser == null)
{
EUserBLL eUserBLL = new EUserBLL();
//lxf TODO:需通过Federation获取用户信息
currentuser = eUserBLL.GetLoginUserInfo(HttpContext.Current.User.Identity.Name);
}
return currentuser;
}
}
/// <summary>
/// 获取当前用户所属角色
/// </summary>
public List<ERoleInfo> CurrentRole
{
get
{
RoleBll = new ERoleBLL();
return RoleBll.GetOPRoleList(this.CurrentUser.UserId);
}
}
#endregion
#region 菜单
/// <summary>
/// 菜单
/// </summary>
/// <returns></returns>
public string GetMenu()
{
string strLeftMenu = "";
string strHeaderMenu = "<div class=\"nav\" id=\"nav\"> <ul>";
EMenuBLL MenuBll = new EMenuBLL();
// 根据角色获取菜单树
List<EMenuInfo> MenuList = MenuBll.GetRoleMenuTree(this.CurrentRole);
if (MenuList != null)
{
strLeftMenu += "<div class=\"btmenu\" id=\"btmenu\" >";
int iCount=0;
// 遍历一级菜单
foreach (EMenuInfo item in MenuList)
{
if (string.IsNullOrEmpty(item.PageUrl))
{
strHeaderMenu += "<li><a href=\"#\" id=\"a" + item.MenuId + "\" >" + item.MenuName + "</a></li>";
}
else
{
strHeaderMenu += "<li><a href=\""+item.PageUrl+"\" id=\"a" + item.MenuId + "\" >" + item.MenuName + "</a></li>";
}
// 默认显示第一个菜单
if (iCount == 1)
{
strLeftMenu += "<div id=\"" + item.MenuId + "\" >";
}
else
{
strLeftMenu += "<div id=\"" + item.MenuId + "\" style=\"display:none;\">";
}
// 遍历二级菜单
foreach (EMenuInfo detail in item.ChildMenuList)
{
if (detail.ChildMenuList.Count > 0)
{
// 遍历三级菜单
foreach (EMenuInfo details in detail.ChildMenuList)
{
strLeftMenu += "<div class=\"metitle\"><a href=\"#\" >" + detail.MenuName + "</a></div>";
if (!string.IsNullOrEmpty(details.PageUrl))
{
strLeftMenu += "<div class=\"metext\"><a " + "href=\"" + details.PageUrl + "\" target=\"FContent\" >" + details.MenuName + "</a></div>";
}
else
{
strLeftMenu += "<div class=\"metext\"><a " + "href=\"#\" >" + details.MenuName + "</a></div>";
}
}
}
else
{
if (!string.IsNullOrEmpty(detail.PageUrl))
{
strLeftMenu += "<div class=\"metitle\"><a " + "href=\"" + detail.PageUrl + "\" target=\"FContent\" >" + detail.MenuName + "</a></div> <div> </div>";
}
else
{
strLeftMenu += "<div class=\"metitle\"><a " + "href=\"#\" >" + detail.MenuName + "</a></div> <div> </div>";
}
}
}
strLeftMenu += "</div>";
iCount++;
}
strLeftMenu += "</div>";
strHeaderMenu += "</ul> </div>";
}
return strHeaderMenu + strLeftMenu;
}
#endregion
#region 设置控件为只读
/// <summary>
/// 设置控件为只读
/// </summary>
/// <param name="_Control">Web控件</param>
protected void SetControlReadOnly(Control _Control, bool isShow)
{
if (_Control is WebControl)
{
WebControl __Control = (WebControl)_Control;
if (isShow)
__Control.Attributes["style"] = "display:block";
else
__Control.Attributes["style"] = "display:none";
}
else if (_Control is HtmlControl)
{
HtmlControl __Control = (HtmlControl)_Control;
if (isShow)
__Control.Attributes["style"] = "display:block";
else
__Control.Attributes["style"] = "display:none";
}
}
#endregion
#region 通用方法
public void Alert(string message)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language='javascript'>alert('" + message + "');</script>");
}
/// <summary>
/// 显示IE浏览器端的对话框
/// </summary>
/// <param name="Message">信息</param>
/// <param name="page">源页面</param>
/// <param name="IsClose">是否关闭窗口</param>
public void MessageBox(string Message, System.Web.UI.Page page, bool IsClose)
{
Type cstype = page.GetType();
if (IsClose)
{
page.ClientScript.RegisterStartupScript(cstype, "MessageBox", string.Format("<script>alert('{0}');top.window.opener=null;top.window.close();</script>", Message));
}
else
{
page.ClientScript.RegisterStartupScript(cstype, "MessageBox", string.Format("<script>alert('{0}');</script>", Message));
}
}
public void Confirm(string message)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language='javascript'>return window.confirm('" + message + "');</script>");
}
protected void CloseWindow(string sParentUrl)
{
string sScript = "<script language=javascript>\n";
sScript += "window.close();\n";
if (sParentUrl != "")
{
sScript += "window.opener.location.href=\"" + sParentUrl + "\"";
}
sScript += "</script>";
ClientScript.RegisterStartupScript(this.GetType(), "close", sScript);
}
public void GoToUrl(string goUrl)
{
ClientScript.RegisterStartupScript(this.GetType(), "location", "<script language='javascript'>window.location.href='" + goUrl + "';</script>");
}
public void OpenWindow(string url)
{
ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "<script language='javascript'>window.open('" + url + "');</script>");
}
public void AlertGoUrl(string alertMessage, string goUrl)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language='javascript'>alert('" + alertMessage + "');window.location.href='" + goUrl + "';</script>");
}
public void AlertAndBack(string alertMessage)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language='javascript'>alert('" + alertMessage + "');window.history.back();';</script>");
}
public void CloseWindowOK()
{
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindowOK", "<script language='javascript'>window.opener='abc';window.returnValue=true;window.close();</script>");
}
public void GoUrl(string message)
{
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindowOK", "<script language='javascript'>window.alert('" + message + "');</script>");
}
#region RegClientScript
/// <summary>
/// 向客户端浏览器注册脚本
/// </summary>
/// <param name="key">键</param>
/// <param name="script">脚本代码</param>
protected void RegClientScript(string key, string script)
{
string scr = "<script language='javascript'>" + script + "</script>";
ClientScriptManager client = Page.ClientScript;
System.Type cstype = Page.GetType();
if (!client.IsClientScriptBlockRegistered(key))
client.RegisterClientScriptBlock(cstype, key, scr);
}
#endregion
#endregion
}
}
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Web.UI.HtmlControls;
using System.Web.UI;
using System.Web.UI.WebControls;
using MCS.WDEDUCloud.Common.DataModel;
using MCS.WDEDUCloud.Common.Business.OP;
using MCS.WDEDUCloud.Common.Utility;
namespace MCS.WDEDUCloud.Portal.OP.Base
{
public class BasePage : System.Web.UI.Page
{
#region UserInfo
ERoleBLL RoleBll;
private EUserInfo currentuser = null;
/// <summary>
/// 当前登录人
/// </summary>
public EUserInfo CurrentUser
{
get
{
if (currentuser == null)
{
EUserBLL eUserBLL = new EUserBLL();
//lxf TODO:需通过Federation获取用户信息
currentuser = eUserBLL.GetLoginUserInfo(HttpContext.Current.User.Identity.Name);
}
return currentuser;
}
}
/// <summary>
/// 获取当前用户所属角色
/// </summary>
public List<ERoleInfo> CurrentRole
{
get
{
RoleBll = new ERoleBLL();
return RoleBll.GetOPRoleList(this.CurrentUser.UserId);
}
}
#endregion
#region 菜单
/// <summary>
/// 菜单
/// </summary>
/// <returns></returns>
public string GetMenu()
{
string strLeftMenu = "";
string strHeaderMenu = "<div class=\"nav\" id=\"nav\"> <ul>";
EMenuBLL MenuBll = new EMenuBLL();
// 根据角色获取菜单树
List<EMenuInfo> MenuList = MenuBll.GetRoleMenuTree(this.CurrentRole);
if (MenuList != null)
{
strLeftMenu += "<div class=\"btmenu\" id=\"btmenu\" >";
int iCount=0;
// 遍历一级菜单
foreach (EMenuInfo item in MenuList)
{
if (string.IsNullOrEmpty(item.PageUrl))
{
strHeaderMenu += "<li><a href=\"#\" id=\"a" + item.MenuId + "\" >" + item.MenuName + "</a></li>";
}
else
{
strHeaderMenu += "<li><a href=\""+item.PageUrl+"\" id=\"a" + item.MenuId + "\" >" + item.MenuName + "</a></li>";
}
// 默认显示第一个菜单
if (iCount == 1)
{
strLeftMenu += "<div id=\"" + item.MenuId + "\" >";
}
else
{
strLeftMenu += "<div id=\"" + item.MenuId + "\" style=\"display:none;\">";
}
// 遍历二级菜单
foreach (EMenuInfo detail in item.ChildMenuList)
{
if (detail.ChildMenuList.Count > 0)
{
// 遍历三级菜单
foreach (EMenuInfo details in detail.ChildMenuList)
{
strLeftMenu += "<div class=\"metitle\"><a href=\"#\" >" + detail.MenuName + "</a></div>";
if (!string.IsNullOrEmpty(details.PageUrl))
{
strLeftMenu += "<div class=\"metext\"><a " + "href=\"" + details.PageUrl + "\" target=\"FContent\" >" + details.MenuName + "</a></div>";
}
else
{
strLeftMenu += "<div class=\"metext\"><a " + "href=\"#\" >" + details.MenuName + "</a></div>";
}
}
}
else
{
if (!string.IsNullOrEmpty(detail.PageUrl))
{
strLeftMenu += "<div class=\"metitle\"><a " + "href=\"" + detail.PageUrl + "\" target=\"FContent\" >" + detail.MenuName + "</a></div> <div> </div>";
}
else
{
strLeftMenu += "<div class=\"metitle\"><a " + "href=\"#\" >" + detail.MenuName + "</a></div> <div> </div>";
}
}
}
strLeftMenu += "</div>";
iCount++;
}
strLeftMenu += "</div>";
strHeaderMenu += "</ul> </div>";
}
return strHeaderMenu + strLeftMenu;
}
#endregion
#region 设置控件为只读
/// <summary>
/// 设置控件为只读
/// </summary>
/// <param name="_Control">Web控件</param>
protected void SetControlReadOnly(Control _Control, bool isShow)
{
if (_Control is WebControl)
{
WebControl __Control = (WebControl)_Control;
if (isShow)
__Control.Attributes["style"] = "display:block";
else
__Control.Attributes["style"] = "display:none";
}
else if (_Control is HtmlControl)
{
HtmlControl __Control = (HtmlControl)_Control;
if (isShow)
__Control.Attributes["style"] = "display:block";
else
__Control.Attributes["style"] = "display:none";
}
}
#endregion
#region 通用方法
public void Alert(string message)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language='javascript'>alert('" + message + "');</script>");
}
/// <summary>
/// 显示IE浏览器端的对话框
/// </summary>
/// <param name="Message">信息</param>
/// <param name="page">源页面</param>
/// <param name="IsClose">是否关闭窗口</param>
public void MessageBox(string Message, System.Web.UI.Page page, bool IsClose)
{
Type cstype = page.GetType();
if (IsClose)
{
page.ClientScript.RegisterStartupScript(cstype, "MessageBox", string.Format("<script>alert('{0}');top.window.opener=null;top.window.close();</script>", Message));
}
else
{
page.ClientScript.RegisterStartupScript(cstype, "MessageBox", string.Format("<script>alert('{0}');</script>", Message));
}
}
public void Confirm(string message)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language='javascript'>return window.confirm('" + message + "');</script>");
}
protected void CloseWindow(string sParentUrl)
{
string sScript = "<script language=javascript>\n";
sScript += "window.close();\n";
if (sParentUrl != "")
{
sScript += "window.opener.location.href=\"" + sParentUrl + "\"";
}
sScript += "</script>";
ClientScript.RegisterStartupScript(this.GetType(), "close", sScript);
}
public void GoToUrl(string goUrl)
{
ClientScript.RegisterStartupScript(this.GetType(), "location", "<script language='javascript'>window.location.href='" + goUrl + "';</script>");
}
public void OpenWindow(string url)
{
ClientScript.RegisterStartupScript(this.GetType(), "OpenWindow", "<script language='javascript'>window.open('" + url + "');</script>");
}
public void AlertGoUrl(string alertMessage, string goUrl)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language='javascript'>alert('" + alertMessage + "');window.location.href='" + goUrl + "';</script>");
}
public void AlertAndBack(string alertMessage)
{
ClientScript.RegisterStartupScript(this.GetType(), "alert", "<script language='javascript'>alert('" + alertMessage + "');window.history.back();';</script>");
}
public void CloseWindowOK()
{
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindowOK", "<script language='javascript'>window.opener='abc';window.returnValue=true;window.close();</script>");
}
public void GoUrl(string message)
{
ClientScript.RegisterStartupScript(this.GetType(), "CloseWindowOK", "<script language='javascript'>window.alert('" + message + "');</script>");
}
#region RegClientScript
/// <summary>
/// 向客户端浏览器注册脚本
/// </summary>
/// <param name="key">键</param>
/// <param name="script">脚本代码</param>
protected void RegClientScript(string key, string script)
{
string scr = "<script language='javascript'>" + script + "</script>";
ClientScriptManager client = Page.ClientScript;
System.Type cstype = Page.GetType();
if (!client.IsClientScriptBlockRegistered(key))
client.RegisterClientScriptBlock(cstype, key, scr);
}
#endregion
#endregion
}
}
发表评论
-
SQL Server附加数据库提示5120错误解决
2014-05-15 15:16 672 -
电话验证
2014-04-09 10:47 483private const string REG_M ... -
.net面试题
2014-04-02 11:15 809相册 广场 ... -
.net面试题
2014-04-02 11:12 1152登录 首页 专栏 专 ... -
new Date(myDateString)在IE中输出NaN,在火狐和谷歌浏览器中正常
2014-04-01 11:18 947今天在工作中遇到这样一个问题:使用jquery ui的date ... -
日历查看课程(支持从指定日期开始显示日历)
2014-03-31 09:28 648日历查看课程(支持从指定日期开始显示日历),增强浏览器兼容性, ... -
javascript之数组操作
2014-03-18 14:49 2951、数组的创建 var arrayO ... -
一個結合where、group、orderby的linq語法
2014-03-11 18:09 806這個linq語法是之前在寫winform程式時,將DataSe ... -
比较C#中的readonly与const
2014-03-07 10:22 448比较C#中的readonly与const ... -
string和stringBuilder区别
2014-03-07 10:15 642C# String 对象是不可改变的。每次使用 System ... -
SCOPE_IDENTITY和@@IDENTITY的用法
2013-12-07 16:39 1818SCOPE_IDENTITY和@@IDENTITY的 ... -
C#.net cookie、session实现自动登陆
2013-11-08 13:35 1901C#.net cookie、session实现 ... -
多条件查询的存储过程的写法
2013-11-04 15:07 504USE [ESD] GO /****** Object: S ... -
多条件查询的存储过程的写法
2013-11-04 15:06 536USE [ESD] GO /****** Object: S ... -
linq left join
2013-11-04 15:04 722linq left join var list = fro ... -
HttpHandler和HttpModule
2013-11-04 15:03 622HttpHandler和HttpModule ... -
如何过滤一个集合
2013-10-10 18:45 654List<Lenovo.SDI.ESD.Entiti ... -
DropdownList动态控制显示的值
2013-10-10 18:43 623DropdownList.Items.Insert(0, ne ... -
asp.net的<% %>总结
2013-08-30 17:01 722asp.net的<% %>总结 ... -
trim
2013-08-30 14:04 390string auditorsName.Trim(','); ...
相关推荐
BasePage中存放了页面的公用资料 Default继承BasePage,并使用IProgramer类库 IProgramer类库: InterfaceTest 被页面使用的接口 clsVBProgramer 继存接口InterfaceTest ,实现一种功能 ...
例如,在上面的例子中,我们可以使用BasePage类的公共方法header()、footer()和left(),而不需要在每个页面类中重复编写这些方法。 继承的好处: 1. 降低代码耦合度:继承可以降低类之间的耦合度,使得代码更加...
在这个例子中,`TestLoginPage`包含了登录功能的测试用例。`setUp`方法用于初始化`BasePage`类的实例,`test_login_success`方法调用了Page Object提供的方法来完成登录操作并验证登录是否成功。 总的来说,结合...
在这个例子中,`LoginPage`类继承了`BasePage`,并定义了与登录页面交互的方法。这样,即使页面元素的定位发生改变,我们只需修改对应页面类中的代码,而不会影响其他部分。 "auto_framework_demo"可能是压缩包内的...
基本例子生产实例如何使用它? 将安装到共享项目中Install-Package Xamarin.Forms.Breadcrumb要添加到页面,我们要做的第一件事是告诉XAML页面可以在何处找到面包屑控件,这是通过向ContentPage添加以下属性来完成...
在这个例子中,Python作为主要的编程语言,用来编写测试脚本和实现自动化测试框架。 2. Selenium:Selenium 是一个强大的Web应用程序自动化测试工具,它可以模拟用户与浏览器的交互,如点击按钮、填写表单等。在这...
在这个例子中,`Login.page`声明了三个抽象属性:`userName`、`passWord`和`message`,这些属性将在`Login.java`中实现。`page-specification`标签指定了页面的Java类,`description`标签用于添加页面的描述,而`...
序列化帮助类,还有例子 SerializeHelper 序列化帮助类,Xml序列化,Json序列化,SoapFormatter序列化,BinaryFormatter序列化 27.压缩解压缩 SharpZip 28.验证码 YZMHelper Captcha 验证码类,一个很个性的...
序列化帮助类,还有例子 SerializeHelper 序列化帮助类,Xml序列化,Json序列化,SoapFormatter序列化,BinaryFormatter序列化 27.压缩解压缩 SharpZip 28.验证码 YZMHelper Captcha 验证码类,一个很个性的...