- ASP.NET 3.5 Application Architecture and Design
- Vivek Thakur
- 289字
- 2021-05-28 17:47:11
Code-Behind Model: The Second UI Layer
In the above classic ASP style example, we noticed that the code and HTML were separated but still present on the same ASPX page. ASP.NET introduced further separation using the principle of code-behind classes, by pulling all of the code out from the ASPX into a separate class and compiling it to a separate DLL. (Note that a DLL is not really required either, if the developer wishes to deploy the code-behind into the web directory. ASP.NET will compile the code "Just-In-Time" into a temporary DLL, so "pre-compiling into a DLL" is not required either.) This allowed the programmers to debug their applications more efficiently and also introduced further loose coupling in the UI layer, introducing another layer into the above 1-tier architecture.
Here is a diagrammatic representation of the above style:

The partial class compilation model was introduced with ASP.NET 2.0. Partial classes help us break up a main class into sibling classes, which can be merged later into one single class by the compiler. We can see that now instead of having a single ASPX file, we have three separate files for a webform—an ASPX file containing HTML UI elements, a code-behind file containing logical code, and an extra designer class file which is auto-generated by the VS and has the declaration of all of the server controls used in the ASPX form. At runtime, the code-behind class is compiled together with the designer.cs
class (containing protected control declarations), and this merged class is used as the base class for the ASPX form class. This approach helped separate the UI code from the HTML elements, and this logical separation in terms of code-behind classes was the second layer style.

- CorelDRAW X6圖形設(shè)計(jì)立體化教程
- Photoshop CS6 商業(yè)應(yīng)用案例實(shí)戰(zhàn)
- VMware虛擬化與云計(jì)算:vSphere運(yùn)維卷
- Spring Security 3
- Creo 6.0快速入門、進(jìn)階與精通(升級(jí)版)
- 好的PPT會(huì)說話:如何打造完美幻燈片
- 新媒體美工一冊(cè)通(全彩)
- 24小時(shí)學(xué)會(huì)PowerPoint 2010
- NetLogo多主體建模入門
- Photoshop CS6中文版基礎(chǔ)與實(shí)例教程(第6版)
- Photoshop移動(dòng)UI設(shè)計(jì)從入門到精通
- CorelDRAW X6核心應(yīng)用案例教程(全彩慕課版)
- Photoshop CS6數(shù)碼照片處理入門到精通
- 中文版Photoshop CS6完全自學(xué)手冊(cè)(超值版)
- 24小時(shí)學(xué)會(huì)Word-Excel-PowerPoint 2010三合一