1, the problem background
Now, more and more people are trying to make web development without refreshing based on Ajax, but in the. NET environment, it is not very convenient to apply Ajax, which may be caused by some of the following reasons:
• Because Ajax is based on the nature of JavaScript, developers must be very knowledgeable about JavaScript, at least, its JavaScript ability to achieve the callback return content to the page update, so the threshold for the development of a certain degree of increase
• When the development based on Ajax mechanism, the original based on postback mode, asp.net by the background logic code (MODEL), aspx page (View), Aspx.cs (Controller) of the MVC framework is actually invalid, When callback returns data, either the return content is parsed with JavaScript on the client side to implement the update, or the more complete HTML code must be constructed on the server side, and then the constructed HTML is set to a Page object directly by JavaScript. Obviously, this way, to achieve one of the simplest callback functions, a lot of code, and is relatively messy code, even in the upcoming asp.net2.0 the problem will not be effectively resolved
2. The purpose of this article
The purpose of this paper is to benefit the characteristics of the existing asp.net itself and Ajax features, and to propose an MVC scheme for Web development based on Ajax in the ASP.NET environment to achieve the following main purposes:
· A clear MVC framework for Ajax in asp.net environments
• Reduce the programmer's reliance on excessive JavaScript coding to reduce the programming threshold
• Flexible support for common development methods in AJAX mode
3, problem analysis
How to achieve the above several main purposes?
1 to the XMLHttpRequest for better encapsulation, so that the way to invoke simpler;
2) As far as possible in the server to update the structure of the data, but also to avoid each return data are manually constructed, so, think of the full use of UserControl, by UserControl as "View", corresponding by the Ascx.cs file as " Controller ", this composition of MVC is also relatively clear;