当前位置: 代码迷 >> 综合 >> asp.net 页面基类
  详细解决方案

asp.net 页面基类

热度:79   发布时间:2024-01-21 03:25:41.0

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

 

/// <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);
    }


}
  相关解决方案