/// <summary>
///first write by 李天平
///up by ahuinan 2009-4-18
/// </summary>
public class PageBase:System.Web.UI.Page
{
public PageBase()
{
//
//TODO: 在此處添加構造函數邏輯
//
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
this.Load += new System.EventHandler(PageBase_Load);
this.Error += new System.EventHandler(PageBase_Error);
}
//錯誤處理
protected void PageBase_Error(object sender, System.EventArgs e)
{
string errMsg = string.Empty;
Exception currentError = HttpContext.Current.Server.GetLastError();
errMsg += "<h1>系統錯誤:</h1><hr/>系統發生錯誤, " +
"該信息已被系統記錄,請稍后重試或與管理員聯系。<br/>" +
"錯誤地址: " + Request.Url.ToString() + "<br/>" +
"錯誤信息: " + currentError.Message.ToString() + "<hr/>" +
"<b>Stack Trace:</b><br/>" + currentError.ToString();
HttpContext.Current.Response.Write(errMsg);
Server.ClearError();
}
private void PageBase_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
if (HttpContext.Current.Session["username"] != null)
{
HttpContext.Current.Response.Write("搜索吧sosuo8.com登陸測試");
}
else
{
HttpContext.Current.Response.Write("你不是阿會楠,不要登陸");
}
}
}
}
使用的時候:
代碼如下:
public partial class _Default :PageBase
{
protected void Page_Load(object sender, EventArgs e)
{
int ID = int.Parse(Request.QueryString["ID"]);
Response.Write("id:"+ID.ToString());
}
}
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com