For ASP.net AJAX application development, it is very useful to use partial rendering, mainly because of its inherent simplicity-less impact on existing pages and less skill requirements for developers. However, partial rendering is simply a trick to bypass the browser in the process of performing a postback request. Using partially rendered pages is not really an AJAX page, because they still depend on the previous postback method. So what exactly is a real AJAX application?
In fact, a real AJAX application uses the XMLHttpRequest object to bypass the browser and establish direct communication with the WEB server and any managed HTTP endpoints. The application can retrieve the necessary data asynchronously and refresh individual blocks of the user interface separately. Many AJAX frameworks are designed based on this critical behavior, which includes a number of syntactic modifications, large or small feature sets, and a rich or simple user Interface widget series. ASP.net AJAX is one of the frameworks.
Designing and building real AJAX applications is not an easy task, even more difficult without the right programming tools. Compared with other AJAX frameworks, the advantage of ASP.net Ajax is embodied in its support for accessing server-side code. From a developer's point of view, using ASP.net AJAX to connect to scriptable Web or windows®communication Foundation (WCF) services is as simple as playing games with children. When you reference a URL, the framework generates a JAVASCRIPT proxy class for you. This is done easily and effectively. Proxy classes Hide XMLHttpRequest details, serialization and deserialization, data formats, and all the details of HTTP packaging. You can simply call a method asynchronously to obtain a pure data transfer object (DTO) with its own set of attributes.
However, ASP.net AJAX does not provide a mechanism that is so efficient and can use the download data in the browser. Of course, this will improve quickly, but now ASP.net AJAX provides a client UI model that is not as rich as the server-side service model.
So how can you now improve the UI model for ASP.net AJAX-only Web applications? Last month, I introduced the concept of a Single-page interface (SPI) and provided several simple patterns that you can use to build an SPI page. This month, I'll discuss client templates and data binding.
Typical AJAX Features
An application that retrieves stock quotes in real time is a typical example of how powerful AJAX methods are. Today, non-AJAX Web sites that provide this feature either use relay refresh tags or plug-in based methods such as Flash, silverlight™, or ActiveX® controls. Typically, you bind the list of stock values that you want to display to a server-side grid control, and then refresh the grid with the rest of the page during the next postback or page request. Using partial rendering can quickly improve this type of page. Let's see how it's done. The markup in Figure 1 encapsulates the grid control in a UpdatePanel control, which is refreshed periodically by the Timer control.
Figure 1 The UI for the live Stock quotes page
<asp:updatepanel runat= "Server" id= "UpdatePanel1" updatemode= "Conditional" > <ContentTemplate> <div Style= "margin:10px;" > <asp:label runat= "Server" id= "Label2"/> <asp:gridview id= "GridView1" runat= "Server" skinid= "CLASSICGR ID "autogeneratecolumns=" false "onrowdatabound=" GridView1_RowDataBound "> <Columns> <asp:bound
Field datafield= "symbol" headertext= "symbol"/> <asp:boundfield datafield= "Quote" headertext= "Last" > <itemstyle horizontalalign= "right"/> </asp:BoundField> <asp:boundfield datafield= ' Change Header '
text= "Change" > <itemstyle horizontalalign= "right"/> </asp:BoundField> </Columns> </asp:GridView> <small><asp:label runat= "Server" id= "Label1"/></small> </div> </co ntenttemplate> <Triggers> <asp:asyncpostbacktrigger controlid= "Timer1" eventname= "Tick"/> </ Triggers> ≪/asp:updatepanel> <asp:timer runat= "Server" id= "Timer1" enabled= "true" interval= "600000" ontick= "Timer1_Tick" "/>