Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

Top 10 ASP.NET AJAX Interview Questions

, 28 Apr 2014 CPOL
Rate this:
Please Sign up or sign in to vote.
Exploring key features/capabilities of ASP.NET and getting answers for ASP.NET Interview Questions in this Web Development Tutorial series, we have reached this Part-5 with a set of questions on ASP.NET and AJAX (Asynchronous JavaScript and XML).What we have covered so far can be summarized as follo
Exploring key features/capabilities of ASP.NET and getting answers for ASP.NET Interview Questions in this Web Development Tutorial series, we have reached this Part-5 with a set of questions on ASP.NET and AJAX (Asynchronous JavaScript and XML).

What we have covered so far can be summarized as follows:

So, let's keep exploring further ASP.NET technology concepts through Interview Questions Series.

Define AJAX?

AJAX stands for "Asynchronous JavaScript and XML". It's basically a technique for creating Rich Internet 

Applications (RIA) that are faster as well as more interactive, using a combination of commonly used techniques as HTML/XHTML, CSS, Document Object Model (DOM), JavaScript, XML/XSLT and XMLHttpRequest object.

XMLHttpRequest object is the key basis of AJAX and makes it possible to communicate with the web server asynchronously and exchange data.

Please elaborate XMLHttpRequest Object further?

XMLHttpRequest is the core object in AJAX technology regardless of any implementation. XMLHttpRequest object is used to exchange data with a server seamlessly. Basically JavaScript uses this Object to exchange XML as well as text data between client and server. An AJAX implementation uses this object and communicate with server but it doesn't require the complete page to be refreshed.

How to send a request to server using XMLHttpRequest Object?

We can send a request to server using HTTP GET and POST methods as follows:

//Simple GET Request
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("GET", "TestFile.txt", true);
xmlHttp.send();

//Simple POST Request
var xmlHttp = new XMLHttpRequest();
xmlHttp.open("POST", "TestFile.txt", true);
xmlHttp.send();

What is ASP.NET AJAX?

Microsoft provided an implementation of AJAX functionality known as ASP.NET AJAX. As we discussed in above interview question that AJAX is a combination of various techniques, so Microsoft simplified the usage of these techniques with its own implementation. ASP.NET AJAX is a set of extensions to ASP.NET and comes with reusable AJAX controls. Using ASP.NET AJAX, we can develop applications that can update partial page instead of a complete page refresh.

Difference between Synchronous and Asynchronous Postback?

In Synchronous postback, complete web page is sent to server and in return rendering the output (i.e. complete page), whereas in case of Asynchronous postback, partial page goes to the server and renders only partial (required) part of the page.

What are the basic controls in ASP.NET AJAX?

Following controls can be considered as core AJAX controls in ASP.NET.

  • ScriptManager
  • ScriptManagerProxy
  • UpdatePanel
  • UpdateProgress
  • Timer

Later more controls are added to ASP.NET AJAX library e.g. Script Loader, Client Data Context, Client Data Access, jQuery Integration etc.

What is a ScriptManager in ASP.NET AJAX?

In order to use AJAX functionality on a web page, we add a ScriptManager control to the page in most of the scenarios, because ScriptManager control register AJAX library scripts to that particular web page. We can have only one ScriptManager per page.

<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>

ScriptManager basically manages all ASP.NET AJAX resources of a web page, creates proxies for asynchronous web service call and also manages partial page updates... etc.

ScriptManager Vs ScriptManagerProxy?

As we understand that we can have only one ScriptManager control on a page but we can have multiple ScriptManagerProxy controls. Consider a scenario that we have ScriptManager in our MasterPage that is available for all content pages. Now, we wanted to register a web service in a particular page. So, we will not add another ScriptManager to that page instead we will add ScriptManagerProxy to it in order to avoid error.

What is the role of UpdatePanel in ASP.NET AJAX?

UpdatePanel is the control that facilitate the partial page rendering functionality in an ASP.NET application. As discussed earlier that using ASP.NET AJAX, we can communicate with a web server asynchronously and update a part of a page without a complete page postback. In order to apply partial page update/rendering, we can add one or more UpdatePanel controls to our ASP.NET Page as follows:

   <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="lblPanel" runat="server" Text="Update Panel Added."></asp:Label><br />
                <asp:Button ID="btnTestButton" 
                                   runat="server" 
                                  OnClick="btnTestButton_Click" 
                                  Text="Test Button" />
      </ContentTemplate>
    </asp:UpdatePanel>   <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
            <ContentTemplate>
                <asp:Label ID="lblPanel" runat="server" Text="Update Panel Added."></asp:Label><br />
                <asp:Button ID="btnTestButton" 
                                   runat="server" 
                                  OnClick="btnTestButton_Click" 
                                  Text="Test Button" />
      </ContentTemplate>
    </asp:UpdatePanel>

What are the limitations of AJAX?

  • AJAX on an application will not work if JavaScript is disabled.
  • In some scenarios, it exposes vulnerability.
  • It will always be difficult to bookmark application state.
  • Application behavior may be slow in some scenarios, because of different loading time of controls on a single page.

Hopefully, this ASP.NET Tutorial will clear more concepts about AJAX technology usage in ASP.NET.

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Imran Abdul Ghani
Software Developer (Senior) Emaratech
United Arab Emirates United Arab Emirates
Imran Abdul Ghani has more than 10 years of experience in designing/developing enterprise level applications. He is Microsoft Certified Solution Developer for .NET(MCSD.NET) since 2005. You can reach his blogging at WCF Tutorials, Web Development, SharePoint for Dummies.
Follow on   Twitter   Google+   LinkedIn

Comments and Discussions

 
Questionarticle PinmemberMojtabaKojouri14-May-14 0:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141220.1 | Last Updated 28 Apr 2014
Article Copyright 2014 by Imran Abdul Ghani
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid