This column is based on a pre-release version of the ASP.net MVC Framework. All information is subject to change.
In layered Web applications, the presentation layer is as important as navigation logic, business logic, and data access. You should try to isolate the presentation layer (usually the presentation logic) from the UI technology and platform, although this is not easy to do. Design patterns can help you achieve this goal.
In this month's column, I'll describe some of the design patterns that are used to build the ASP.net presentation layer. The first thing I want to introduce is the model-view-controller (MVC) pattern (the root pattern for all specialized UI-oriented schemas) and its asp.net applicability beyond the scope of the ASP.net MVC framework.
Deep understanding of ASP.net event handlers
The ASP.net presentation layer consists primarily of. aspx pages that match the HTTP run-time environment. Sometimes, a typical. aspx page may make an HTTP request based on the actions of a particular user, such as a button click or List selection. In asp.net Web forms programming, these events are typically handled sequentially by methods and event handlers, and then written in the page's code-behind class. On the surface, user actions and system reactions seem to be directly connected, which may be true in desktop applications, but not in asp.net.
In ASP.net, a lot of things happen from the time the user clicks to the Display update page, regardless of whether you are currently using AJAX, but in the ASP.net application that you build with the ASP.net MVC Framework, the flow of information is shorter.
Let's look at a button click event. The developer handles this event by writing some code in the Click event handler of the Button control. These codes exist in the source code of the page, as follows:
void Button1_Click (object sender, EventArgs e)
{
//perform any required action
}
You can put all the code that you need to do here, or you can group all of these code in a static method or an instance method exposed by an object:
void Button1_Click (object sender, EventArgs e)
{
//Static method bound to the user action
actionmanager.b Utton1clicked ();
}
You can also organize code that responds to users ' activities in the Controller and operations:
void Button1_Click (object sender, EventArgs e)
{
//Static method bound to the user action
Thispagec Ontroller controller = new
Thispagecontroller ();
Controller. Button1clicked ();
}