现在的位置: 首页 > 综合 > 正文

asp.net 页面基类

2014年01月05日 ⁄ 综合 ⁄ 共 2284字 ⁄ 字号 评论关闭

包括存全局变量、权限判断等基本功能

 

/// <summary>
/// 页面基类
/// </summary>

public class PageBase:System.Web.UI.Page
{
    
public PageBase()
    
{
    }

    
private Globals siteGlobals=new Globals();


    
protected virtual void Page_Load(object sender, EventArgs e)
    
{
        CheckUserInfo();
    }

    
属性

    
/// <summary>
    
/// 判断是否具该系统权限且是否登录
    
/// </summary>

    public void CheckUserInfo()
    
{
        
if (MyInfo != null)
        
{
            
if (MyInfo.SysType != 2 && MyInfo.SysType != 0)
            
{
                Response.Redirect(AppPath 
+ "ErrorPage.Aspx?ErrorMsg=您没有权限登录该系统!"true);
            }

        }

        
else
        
{
            Response.Redirect(AppPath 
+ "Main/Login.aspx"true);
        }

    }


    
protected override void OnInit(EventArgs e)
    
{
        
if (!SiteGlobals.SiteOpenFlag)
            Response.Redirect(AppPath 
+ "ErrorPage.Aspx?ErrorMsg=网站被关闭,暂时不能访问!"true);
        
this.Load+=new EventHandler(this.Page_Load);
        
base.OnInit(e);
    }



    
protected override void OnUnload(EventArgs e)
    
{
        
base.OnUnload(e);
    }


}

抱歉!评论已关闭.