User controls in Aspx vs. include methods in ASP _ Practical Tips

Source: Internet
Author: User

In the era of ASP, in order to avoid frequent duplication of labor, a number of similar functions of the region or code, often made a file, and then through the connection (direct connection or virtual connection) method into the ASP Web page file, For a large number of references to a lot of ASP files is equivalent to a file is divided into a lot of blocks, the data between the files are free to share (in addition to the data in the function).
The user control for ASPX is very different from include, its greatest characteristic is that he is in the form of packaged objects, through our programming, you can abstract a common case, some functions and methods to sum up, make the corresponding functions and attributes for external event calls, To achieve a complete class, the largest package of external users do not need to understand the internal facts, making it more maintainable, but also improve the security of the data, more conducive to the release of the program.
Simple things easy to use, but naturally also less function, or is very imperfect, we can be free to include a file in the specified ASP file, but, because each other's data can be shared, so that the file interdependence is very high, reduce the code readability, not conducive to the maintenance of the system, at the same time, If there is a picture in the included file, and the contained file is not under the same directory as the file containing the file, the address of the picture of the included file must be the address of the picture in the file that contains the file, such as/file/index. ASP is the primary file (the file that needs to contain the file), and/file/include/title. The ASP is included file, and the picture address is/file/title.jpg at this time need to change the picture address in title.asp to Title.jpg instead of. /title.jpg, otherwise you will not be able to display the picture in the main file, the hyperlink is the same problem.
Complex ASPX solves a lot of problems, if you can set the address of the picture freely in the control file, regardless of the directory that references his file, as long as what can be displayed in the control file can still be used after being referenced, which makes the user made the control more reusable, Unlike an ASP, a file that references the same functionality to a file in a different directory requires two files that are in fact the same but have a picture or hyperlink address. Waste of resources also makes maintenance more expensive. Of course, these advantages also make the document is also more cumbersome to write, for analysis requires a higher inductive capacity, Allows the control to be used more widely.

Related Article

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.