In ASP., any page is inherited from System.Web.UI.Page, and he provides the operation of response,request,session,application in ASP. Using Visual Studio When you create an ASP page, an inherited and System.Web.UI.Page class is automatically associated with the page file for you.
Public Partial class yourpage:system.web.ui.page{ protectedvoid Page_Load (Object Sender,eventargs E ) { }}
We can design a class, such as:
class mypage:system.web.ui.page{ } // In this case we can change The page generated code to public Partialclass yourpage:mypage () {//... ... // in this way, we can put some common methods in mypage to reuse the code more efficiently, and implement the jump function of some error pages.
In addition, there is an important method in page:
protected Override void OnInit (EventArgs e) { base. OnInit (e);
这是页面的初始化时执行的方法,但需要特别注意的是,重写该方法的时候一定要将
base
.OnInit(e)写入,不能留空.
System.Web.UI.Page use, you must learn to be lazy