System.Web.UI.Page use, you must learn to be lazy

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.