Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Using the Ajax.NET Framework

What developer wants to spend hours manually writing Ajax plumbing when the Ajax.NET framework does this for free?


advertisement
he Ajax.NET Framework presents a remarkably easy-to-use framework that will simplify Ajax development and allow developers to spend more time on implementation details and less time on parsing XML. If Ajax is still a new concept for you, Ajax stands for Asynchronous JavaScript and XML. The "XML" part of Ajax my be a little misleading as some methods use other technologies in place of XML for data transfer between the browser and the server. The Ajax.NET Framework uses JSON (JavaScript Object Notation).

Ajax groups these technologies and provides a break from the traditional model requiring a post back to the server in order to run server-side methods. Ajax allows a browser to make calls to server-side code and receive a response from the server all without using the ASP.NET postback, which transfers full ViewState and page information with each request. How Does Ajax Work?
The "magic" of Ajax lies in the use of the HttpRequest object to facilitate communication between the browser and the server. This object will contact the server, call the designated code and wait for a response from the server. The nice part about this system is that since the processing is asynchronous, the Web browser will continue to allow the user to keep working uninterrupted with the Web application while waiting for the server to process requests.

A very simplistic way to think about this technology is to say that in one respect Ajax grants the user the ability to call code-behind methods from JavaScript. Callbacks
Ajax will request a service from the server and wait for a response. The way Ajax applications wait for the response is what makes the applications useful. Once you have sent the request to the server for processing, the browser will continue to do its work. Once the server generates a response the browser will recognize that response and then continue processing.



Even with a few extra server calls you are still sending less data across the wire than you would with traditional postbacks which often include full ViewState information.
You have two options available to you when calling code on the server in an Ajax environment. You may choose to define a callback method or you may choose to simply send a message to the server and allow the application to continue with its work without being notified the operation is complete. If you choose to recognize the response, you will define a callback method in JavaScript. A callback method runs once the browser has recognized a response from the server. Once the callback method is invoked, the application may now conduct some additional processing of the response data as provided by the server.

Implications of N-Tiered Development
Some of the traditional lines of n-tier application architecture may blur when you use Ajax. In an application where you use Ajax but you haven't thought through the architecture, you might have a considerable amount of overlap of business logic in the user interface layer. You want to make sure you keep your architect's hat on while developing Ajax applications. Remember that the business layer should know nothing of how to display information to the user and the user interface should not contain business rules. To accomplish this goal, you should strictly return data to the user interface layer and allow UI services to format the data for the final presentation. An Ajax developer may need to use an interim layer between the business objects and the browser to further prepare server-side data before rendering to the browser.

What Is the Ajax.NET Framework?
The Ajax.NET Framework lies on top of the .NET Framework and abstracts the plumbing for Ajax interaction between the server and browser. What is the difference between Ajax and the Ajax.NET Framework? Ajax.NET is a framework around the technologies that create the Ajax method. Without such a framework you must manually code the client/server communication, which is both error-prone and time consuming. The Ajax.NET Framework dynamically creates proxy objects that act as the communication mechanism between the browser and server. When a developer creates a method in code behind, that method may be decorated with an attribute to tell the Ajax.NET engine to create the necessary JavaScript proxy.

The JavaScript proxy object will have a similar interface to the object as it exists on the server. Using the Ajax.NET Framework, client-side objects will have the same properties as the server-side counterpart. Object methods, however, will not translate from the server side to the proxy object. The proxy is simply a data transfer object and cannot implement server-side logic.



Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap