In ASP. NET factory mode, the implementation of page and page inheritance is used

Source: Internet
Author: User

The ASP. NET page we wrote is post-code, so we inherit the post-code, that is, the XXXX. aspx. cs file. In fact, the inheritance of pages is the same as that of ordinary classes, but ASP. NET page interface is composed of HTML and post-code, so there are also some differences, good to begin with our ASP. NET factory model and page inheritance:

Here I have summarized one in. the UML diagram generated by Rational XDE In the. NET environment gives you an intuitive and perceptual understanding. I will first explain the relationships between classes and them in this diagram, the BillFactory class is the document factory that I defined to identify and generate that kind of document. mongourbillcom is a virtual class or interface. It defines some methods to implement the class that inherits it, issueBillMng_Frm and IssueBill_Frm are the post-code classes of the page. They are responsible for page operations such as button status and calling business logic, billInstorageMngList and IssueBillMng inherit the VirturBillCom virtual class to implement business processing and call the data storage layer. BillInstorageMngList is responsible for processing warehouse receiving orders, and IssueBillMng is responsible for processing warehouse picking orders. BillEntity and BillItemEntity are Entity classes mapped to databases. BillInstorageMng inherits the page class IssueBillMng_Frm, and BillInstorage inherits the page class IssueBill_Frm. As you can see, BillInstorageMng and BillInstorage inherit the page class, so there is only one empty constructor in their class, and others can be processed by its parent class. Here you may want to ask, can we complete page inheritance?

This is only one step. To achieve the same effect as the page of the parent class, you must copy the HTML in the parent class to the HTML of the subclass, in this way, the interface display is the same. If you want to change the interface, you can change the Add button in the HTML of the subclass interface. when HTML is copied to the subclass page in the NET designer, the server control on the page is automatically added to the variable declaration when the post code of the Child page is entered. As we can imagine, these controls already exist in the parent class, and the default protection type is protected, so the subclass can also be seen, so the control will be repeated, it will be very wrong, the control variables used by the parent class must be deleted from the Child class. If the child class wants other operations, you can add the control by yourself, but the variables cannot be the same as the parent class. This completes page inheritance. You can try it to reduce a lot of repeated code.

Also, I want to talk about BillInstorageMngList class and IssueBillMng class. They all inherit from mongourbillcom to implement the functions defined by mongourbillcom. They are intermediate layers, therefore, we can directly call mongourbillcom when calling the page. The actual implementation of which instance is implemented by BillFactory may not be clear, specifically, in the IssueBillMng_Frm constructor, the page constructor does not exist by default. we add it by ourselves) declare an example of javasurbillcom: mgrObr = BillFactorythis); use ASP. NET factory mode to determine the intermediate layer variable of the instance to complete different work. This is the simple ASP. NET factory mode.

  1. Shell functions in ASP. NET Environment
  2. Batch insert data to databases in ASP. NET
  3. ASP. NET sends data to webpages in Post Mode
  4. WEB Application Deployment in ASP. NET 2.0
  5. HttpWorkerRequest object in ASP. NET
  6. Eve of the owc component in ASP. NET 2.0

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.