Go4Expert (http://www.go4expert.com/)
-   -   ASP.NET FAQ (PART I) - Ajax (http://www.go4expert.com/articles/aspnet-faq-part-i-ajax-t17159/)

sanjitsil 27Apr2009 08:06

What is Partial Page Rendering?

Partial page rendering is a concept of rendering only a portion of web a page instead of whole page and thus improve user experience and makes the response time quicker. It can be achieved using Ajax.

What is Ajax?

Ajax means "Asynchronous Javascript and XML" which represents a set of client side technologies (e.g, HTML/XHTML, CSS, Document Object Model or DOM, XML/XSLT, JSON, Javascript and the XMLHttpRequest object) to create Rich Internet Applications using asynchronous communication between user interfaces and web server.

Is Ajax to be installed separately on a server?

For ASP.NET 2.0. we need to download Ajax ControlToolKit separately but in ASP.NET 3.5 Ajax is inbuilt.

What are the benefits of Ajax?
  1. Reduce hits into the server
  2. Reduce network load
  3. Create rich an interactive user interface or UI.
  4. Provides client side and server side framework to work with.
  5. Supports asynchronous communication.
  6. Platform independent
  7. Multibrowser support.
  8. Response time becomes faster.
What is ASP.NET Ajax?

ASP.NET Ajax, formerly known as Atlas, is an extension of ASP.NET2.0. ASP.NET Ajax is a set of technologies to add Ajax support into ASP.NET. There is both client side and server side framework available for ASP.NET Ajax.

What are the most popular Ajax Frameworks?

Most popular Ajax framework includes the followings:
  1. MagicAjax.NET
  2. ComfortASP.NET
  3. Jason Diamond’s Anthem
  4. Michael Schwarz’s Ajax.NET
  5. Microsoft’s Atlas
  6. Microsoft’s ASP.NET Ajax
Server-Side AJAX framework vs. Client-side AJAX framework

Ajax framework comprised of javascript client side libraries and server side asp.net controls which help us to build an Ajax enabled rich web applications.
JavaScript libraries which is independent from ASP.NET and help us to call serverside methods and even web service from client side.

How Ajax is more suitable than iFrame?

Using iFrame we can also achieve partial page rendering facility. But Ajax has the following advantages over iFrame:
  1. Ajax supports asynchronous communication unlike iFrame.
  2. With an iFrame it is not possible to know status whereas we have 5 different status codes for our call: 0 = uninitialized, 1 = loading, 2 = loaded, 3 = interactive, 4 = complete and these are useful to provide the user with more accurate information.
What is synchronous and asynchronous communication?

In synchronous communication a user requests for a page and has to wait until the complete round trip happens. This prevents the client from performing other tasks while waiting for the results of request. On the other hand, in asynchronous communication, the client continues processing other tasks as it waits for a response. The client responds to the result of request when it becomes available.

What is XMLHttpRequest object?

XmlHttpRequest object forms the heart of Ajax applications. XmlHttpRequest object allows the browser to communicate with server with out posting the whole page and only sending the necessary data asynchronously and thus refresh the required data in the page instead of whole page data.

What are the different status of readyState property of XMLHttpRequest object?

The readyState property returns the current state of the object. It has the following status codes:

Status Code
Uninitialized – Object created but not initialized. Open method not yet called.
Loading – Object created but send method not yet called
Loaded – Send method called but status and headers are not yet available
Interactive – Not all data are received
Completed – All data are received and complete data is available in the responseBody and responseText properties.
What is responseText and responseXML ?

The responseText and responseXML both are the properties of XMLhttpRequest object and is used for handling responses. The responseText and responseXML properties hold the string in string and xml format respectively.

What are the main Ajax server controls in ASP.NET?

ASP.NET has come up with the following server controls:
  1. ScriptManager
  2. ScriptManagerProxy
  3. UpdatePannel
  4. UpdateProgress
  5. Timer

The ScriptManager is the most important control for an Ajax enabled web page. We can say it as the heart of Ajax. It provides Client side scripting and access to web service using javascript proxy classes. Using the UpdatePanel control provides partial page rendering capabilities. There can be only one ScriptManager control in an Ajax enabled webpage.


When we want to modify the ScriptManager control of the master page, we should have a scriptManagerproxy control in the content page. It should be noted that in order to use ScriptManagerProxy control in the content page, there should be a ScriptManager control in the master page.


The UpdatePanel control, now built-in as part of ASP.Net 3.5, is responsible for partial page rendering of a web page that means only part of a page is posted back to the server instead of the entire page. This helps to build rich User Interfaces, provides improved performance and quicker response time.


When doing the partial page update in an asynchronous mode of operation, UpdateProgress is very useful control to display the process status. So user can know the percentage of completed task at any point of time.


To update any value or data on an interval basis, the Timer control is useful.

What is PageMethods?

Using PageMethods we can call Server-Side code (C# or VB.NET code) from client side using javascript.

What are the popular data formats are available?
Following are the most popular data formats:
  1. HTML
  2. Plain text or string delimiters
  3. XML
  4. JSON

What is JSON?

JSON (JavaScript Object Notation) is a lightweight data interchange format which is a format derived from JavaScript. It is a good alternative to XML as a data interchange format.

What are the data types supported by JSON?
  1. String
  2. Number
  3. Boolean
  4. Array
  5. Object
  6. Null

What is the purpose of ParseJSON() function?

The ParseJSON() function converts the JSON text into a javaScript object.
The said function is available in www.json.org/json.js

What is the purpose of toJSONString () function?

The toJSONString() function converts the JavaScript objects into JSON text/string.
The said function is available in www.json.org/json.js

What are the datastructure supported by JSON? Briefly describe.

JSON supports two type of datastructure: objects and arrays.
Objects are the collection of name/value pairs. Example:


var objInfo={
“Name”: “Sanjit”,
alert (objInfo.Name); //output “Sanjit”

Using array we can store as follows:

var myColor=[“Red”,”Green”,”Yellow”];
alert (myColor[0]); //output “Red”

What is the purpose of triggers?

Triggers is placed within 'UpdatePanel' tag. Often we need to update the contents in UpdatePanel due to any control's event - that we can achieve using trigger .The Trigger can be generated by any control in the form.


                <asp:AsyncPostBackTrigger ControlID="btnInside" EventName="Click" />
<asp:Button ID="btnInside" runat="server" onclick="Button1_Click" Text="Inside" />

In the above code contents in UpdatePanel1 will be updated when btnInside button will be clicked.
Triggers can be of two types: AsynchronousPostBackTrigger and PostBackTrigger. In the above code AsynchronousPostBackTrigger is used. The PostBackTrigger is responsible for full page post back whereas the AsynchronousPostBackTrigger is responsible for only an Asynchronous PostBack.

What is the purpose of ContentTemplate tag?

The ContentTemplate tag is used to define the contents which will be posted back asynchronously to the server:

        <asp:Label ID="lblUpdatePanel" runat="server" Text="Within UpdatePanel :"></asp:Label>
        <asp:Label ID="lbl1" runat="server" Text="testing"></asp:Label>

What are the most popular applications where Ajax is in use?

GMail – http://mail.google.com
Google Suggest - http://www.google.com/webhp?complete=1&hl=en
Google Maps - http://maps.google.com/
MSN Virtual Earth - http://virtualearth.msn.com/

shabbir 3May2009 11:57

Nominate this article of the month for April 2009

shabbir 18May2009 19:45

Start Voting for article of the month - April 2009

All times are GMT +5.5. The time now is 10:46.