Roadmap of Programming and Development
程式開發的學習藍圖
作者:朱明中
http://www.microsoft.com/taiwan/msdn/columns/jhu_ming_jhong/rop.htm
2008年5月19日 星期一
BasePage
public class BasePage : System.Web.UI.Page
{
public BasePage():base()
{
}
protected override void OnPreLoad(EventArgs e)
{
base.OnPreLoad(e);
if (this.ValidatePermission() == false)
{
throw new Exception("Not Auth");
}
}
============================================================================
protected virtual bool ValidatePermission()
{
return false;
}
}
public partial class _Default : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
this.DataBind();
}
protected override bool ValidatePermission()
{
If( User.Name == "維克大隊長")
{
return true;
}
else
{
return false;
}
}
}
{
public BasePage():base()
{
}
protected override void OnPreLoad(EventArgs e)
{
base.OnPreLoad(e);
if (this.ValidatePermission() == false)
{
throw new Exception("Not Auth");
}
}
============================================================================
protected virtual bool ValidatePermission()
{
return false;
}
}
public partial class _Default : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
this.DataBind();
}
protected override bool ValidatePermission()
{
If( User.Name == "維克大隊長")
{
return true;
}
else
{
return false;
}
}
}
訂閱:
文章 (Atom)