|
|
|
The General Ajax Interview Questions consists the most frequently asked
questions in Ajax. This list of 100+ questions guage your familiarity with
the Ajax platform. The q&a have been collected over a period of time
from various blogs, forums and other similar Php sites
|
1. Ajax Interview Questions Part[1]
|
| 1.1 What is
AJAX?
|
| 1.2 Can Ajax
be implemented in browsers that do not support the XmlHttpRequest object?
|
| 1.3 Can AJAX
technology work on web servers other than IIS?
|
| 1.4 Which
browsers support the XmlHttpRequest object?
|
| 1.5 How to we
create an XmlHttpRequest object for Internet Explorer? How is this different
for other browsers?
|
| 1.6 What are
the properties of the XmlHttpRequest object? What are the different types of
readyStates in Ajax?
|
| 1.7 What is
the ASP.NET Ajax Framework? What versions have been released so far?
|
| 1.8 What are
Ajax Extensions?
|
| 1.9 What is
the ASP.NET Control Toolkit?
|
| 1.10 What is
Dojo?
|
| 1.11 How to
handle multiple or concurrent requests in Ajax?
|
| 1.12 How to
create an AJAX website using Visual Studio?
|
| 1.13 What is
the role of ScriptManager in Ajax?
|
| 1.14 Can we
override the EnablePartialRendering property of the ScriptManager class? value
of $$b?
|
| 1.15 How to
use multiple ScriptManager controls in a web page?
|
| 1.16 Whats
the difference between RegisterClientScriptBlock, RegisterClientScriptInclude
and RegisterClientScriptResource?
|
| 1.17 What
are type/key pairs in client script registration? Can there be 2 scripts with
the same type/key pair name?
|
| 1.18 - What
is an UpdatePanel Control?
|
| 1.19 What
are the modes of updation in an UpdatePanel? What are Triggers of an
UpdatePanel?
|
| 1.20 How to
control how long an Ajax request may last?
|
1.1 What is AJAX?
|
|
Ajax stands for Asynchronous Javascript & XML. It is a web technology
through which a postback from a client (browser) to the server goes partially,
which means that instead of a complete postback, a partial postback is
triggered by the Javascript XmlHttpRequest object. In such a scenario,
web-application users won't be able to view the complete postback progress bar
shown by the browser. In an AJAX environment, it is Javascript that starts the
communication with the web server. Ajax technology in a website may be
implemented by using plain Javascript and XML. Code in such a scenario may tend
to look little complex, for which the AJAX Framework in .NET can be embedded in
ASP.NET web applications. In addition to XML & Javascript, AJAX is also
based on DOM - the Document Object Model technology of browsers through which
objects of the browser can be accessed through the memory heap using their
address. JSON - Javascript Object Notation is also one of the formats used in
AJAX, besides XML. So basically, in an AJAX-based web application, the complete
page does not need to reload, and only the objects in context of ajaxification
are reloaded. Ajax technology avoids the browser flickering.
|
1.2 Can Ajax be implemented in browsers that do not support the XmlHttpRequest
object?
|
|
Yes. This is possible using remote scripts.
|
1.3 Can AJAX technology work on web servers other than IIS?
|
|
Yes, AJAX is a technology independent of web server the web application is
hosted on. Ajax is a client (browser) technology.
|
1.4 Which browsers support the XmlHttpRequest object?
|
|
Internet Explorer 5.0+, Safari 1.2, Mozilla 1.0/Firefox, Opera 8.0 +, Netscape
7
|
1.5 How to we create an XmlHttpRequest object for Internet Explorer? How is
this different for other browsers?
|
|
For Internet Explorer, an ActiveXObject is used for declaring an XmlHttpRequest
object in Javascript.
//Code as below for IE:
xmlHttpObject = new ActiveXObject("Msxml2.XMLHTTP");
//For Other browsers, code as below:
xmlHttpObject = new XMLHttpRequest();
Note that XmlHttpObject used above is simply a variable for the respective
browsers.
|
1.6 What are the properties of the XmlHttpRequest object? What are the
different types of readyStates in Ajax?
|
|
i) onreadyStateChange - This function is used to process the reply from the web
server.
ii) readyState - This property holds the response status of the web server.
There are 5 states:
1 - request not yet initialized
2 - request now set
3 - request sent
4 - request processing
5 - request completes
|
1.7 What is the ASP.NET Ajax Framework? What versions have been released so
far?
|
|
ASP.NET AJAX is a free framework to implement Ajax in asp.net web applications,
for quickly creating efficient and interactive Web applications that work
across all popular browsers. The Ajax Framework is powered with
1 - Reusable Ajax Controls
2 - Support for all modern browsers
3 - Access remote services and data from the browser without tons of
complicated script.
Versions of Ajax release
1 - ASP.NET Ajax Framework 1.0 (earlier release to this was called the Atlas)
2 - ASP.NET Ajax Framework 1.0 was available as a separate download for ASP.NET
2.0
|
1.8 What are Ajax Extensions?
|
|
The ASP.NET Ajax Extensions are set of Ajax-based controls that work in ASP.NET
2 (or above) based applications. Ofcourse,they also need the Ajax runtime which
is actually the Ajax Framework 1.0. ASP.NET Ajax Extensions 1.0 have to be
downloaded to run with ASP.NET 2.0 The new ASP.NET 3.5 Framework comes with the
Ajax Library 3.5 (containing the Ajax Extensions 3.5). So in order to use the
latest Ajax, simply download .NET 3.5 Framework.
|
1.9 What is the ASP.NET Control Toolkit?
|
|
Besides the Ajax Framework (which is the Ajax engine) and Ajax Extensions
(which contain the default Ajax controls), there is a toolkit called the Ajax
Control Toolkit available for use & download (for free). This is a
collection of rich featured, highly interactive controls, created as a joint
venture between Microsoft & the Developer Community.
|
1.10 What is Dojo?
|
|
Dojo is a third-party javascript toolkit for creating rich featured
applications. Dojo is an Open Source DHTML toolkit written in JavaScript. It
builds on several contributed code bases (nWidgets, Burstlib, f(m)), which is
why we refer to it sometimes as a "unified" toolkit. Dojo aims to solve some
long-standing historical problems with DHTML which prevented mass adoption of
dynamic web application development.
|
1.11 How to handle multiple or concurrent requests in Ajax?
|
|
For concurrent requests, declare separate XmlHttpRequest objects for each
request. For example, for request to get data from an SQL table1, use something
like this...
xmlHttpObject1.Onreadystatechange = functionfromTable1();
and to get data from another table (say table2) at the same time, use
xmlHttpObject2.Onreadystatechange = functionfromTable2();
Ofcourse, the XmlHttpObject needs to be opened & parameters passed too,
like as shown below...
xmlHTTPObject1.open("GET","http://"localhost// " + "Website1/Default1.aspx"
true);
Note that the last parameter "true" used above means that processing shall
carry on without waiting for any response from the web server. If it is false,
the function shall wait for a response.
|
1.12- How to create an AJAX website using Visual Studio?
|
|
Using Visual Studio Web Developer Express 2005 & versions above it, Ajax
based applications may easily be created. Note that the Ajax Framework &
Ajax Extensions should be installed (In case of VS 2005). If using Visual
Studio 2008 Web Developer Express or above, Ajax comes along with it (so no
need of a separate installation).
Steps: Start Visual Studio, Click on File -> New Website -> Under Visual
Studio Installed templates -> Select ASP.NET Ajax-Enabled Site. Enter a
location & select OK.
|
1.13 Can we override the EnablePartialRendering property of the ScriptManager
class?
|
|
Yes. But this has to be done before the init event of the page (or during
runtime after the page has already loaded). Otherwise an
InvalidOperationException will be thrown.
|
1.14 How to use multiple ScriptManager controls in a web page?
|
|
No. It is not possible to use multiple ScriptManager control in a web page. In
fact, any such requirement never comes in because a single ScriptManager
control is enough to handle the objects of a web page.
|
1.15 - Whats the difference between RegisterClientScriptBlock,
RegisterClientScriptInclude and RegisterClientScriptResource?
|
|
For all three, a script element is rendered after the opening form tag.
Following are the differences:
1 - RegisterClientScriptBlock - The script is specified as a string parameter.
2 - RegisterClientScriptInclude - The script content is specified by setting
the src attribute to a URL that points to a script file.
3 - RegisterClientScriptResource - The script content is specified with a
resource name in an assembly. The src attribute is automatically populated with
a URL by a call to an HTTP handler that retrieves the named script from the
assembly.
|
1.16 What are type/key pairs in client script registration? Can there be 2
scripts with the same type/key pair name?
|
|
When a script is registered by the ScriptManager class, a type/key pair is
created to uniquely identify the script. For identification purposes, the
type/key pair name is always unique for dentifying a script. Hence, there may
be no duplication in type/key pair names.
|
1.17 What is an UpdatePanel Control?
|
|
An UpdatePanel control is a holder for server side controls that need to be
partial postbacked in an ajax cycle. All controls residing inside the
UpdatePanel will be partial postbacked. Below is a small example of using an
UpdatePanel.
As you see here after running the snippet above, there wont be a full postback
exhibited by the web page. Upon clicking the button, the postback shall be
partial. This means that contents outside the UpdatePanel wont be posted back
to the web server. Only the contents within the UpdatePanel are refreshed.
|
1.18 How to control how long an Ajax request may last?
|
|
Use the ScriptManager's AsyncPostBackTimeout Property. For example, if you want
to debug a web page but you get an error that the page request has timed out,
you may set where the value specified is in seconds.
|
1.19 What are limitations of Ajax?
|
|
An Ajax Web Application tends to confused end users if the network bandwidth is
slow, because there is no full postback running. However, this confusion may be
eliminated by using an UpdateProgress control in tandem.
|
1.20 How to make sure that contents of an UpdatePanel update only when a
partial postback takes place (and not on a full postback)?
|
|
Make use of ScriptManager.IsInAsyncPostBack property (returns a boolean value)
|
|