Separation of program architecture and program code in ASP. Net

Source: Internet
Author: User

A year ago, when I got a PHP program named TWIG, I was immediately impressed by the author's OOP programming idea. It was hard to imagine all the functions of TWIG (calendar, email, and personalization) all in a PHP file (index. php3) execution is complete, thanks to the author's adoption of the idea of separating program code from the page architecture, but I also see that despite the great efforts made by the author, due to the limitations of PHP, the program does not really separate the code from the framework, index. the main file php3 has too many functions to execute, so there are quite a lot of module files in its require, so the entire file is still very messy, I am ignorant, it took half a month, only then can I really understand the framework of the program and analyze the code. No one knows it ......).
The TWIG program has a great impact on my subsequent programming, but even such a piece of work still does not get rid of the mixed situation of program code and HTML code.
Separating program code from page architecture is a dream of WEB programmers for many years. In ASP. before the emergence of Net, both ASP, PHP and JSP, program code and HTML code were mixed together. This approach, although praised in the early stages of WEB technology, but over time, its disadvantage is becoming more and more obvious. When the program code is very long, the HTML code is mixed with it, and the readability of the program becomes very poor, which makes it impossible to distinguish the page architecture that the program really wants to represent.
ASP. Net implements code separation through Codebehind, User Control, and Custom Control. This is an amazing improvement. You can see in this article how clear the structure of ASP. Net program after code separation is.
Here, we will show you how they are implemented. Let's first look at the functions to be implemented.
For ease of understanding, the design page here is relatively simple, the page is divided into three main parts, the header contains an AdRotator control (used to display ads) and a Label control (used to display the current ad link address); the middle is a login page, including two TextBox controls (used to enter the user name and password respectively), a Label control (display whether the login is successful) and a Button control (as the submit Button); the bottom contains two Label controls (display the current user name and user permissions respectively ).
Familiar with ASP. net friends, will immediately realize that the header because of the use of the AdRotator control, so there must be an OnAdCreated event to display the corresponding link in the Label control; and in the middle of the due to the use of the Button control as the submit Button, therefore, an OnClick event must be processed.

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.