ASP.NET中的基页
发布时间:2020-12-15 20:41:14 所属栏目:asp.Net 来源:网络整理
导读:您是否建议在Visual Studio中创建的每个网站,您应该创建一个作为父类的基本页面? 什么是确切的好处/缺点? 解决方法 如果要覆盖ASP.NET中的某些工作方式,将其构建到基类中而不是将代码包含在每个页面中更为有效.我这样做的两个具体实例是: 的IsPostBack 鲜
您是否建议在Visual Studio中创建的每个网站,您应该创建一个作为父类的基本页面?
什么是确切的好处/缺点? 解决方法
如果要覆盖ASP.NET中的某些工作方式,将其构建到基类中而不是将代码包含在每个页面中更为有效.我这样做的两个具体实例是:
的IsPostBack Public Class MyBase Inherits System.Web.UI.Page <DebuggerStepThrough()> _ Public Shadows Function IsPostback() As Boolean 'Check the built-in IsPostback and make sure this is a HTTP POST Return (Page.IsPostBack AndAlso Request.HttpMethod.ToUpper = "POST") End Function End Class 错误处理 public partial MyBase : System.Web.UI.Page { protected void Page_Error (object sender,EventArgs e) { Exception ex = Server.GetLastError(); // Do something with the exception e.g. log it ... Server.Transfer("~/mycustomerrorpage.aspx"); } } (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |