Você está na página 1de 12

AJAX Interview Questions And Answers

Page 1
Ques: 1 What is AJAX ? Ans: AJAX(Asynchronous JavaScript And XML) is not a new programming language, but a new way to use existing standards. AJAX is the art of exchanging data with a server, and update parts of a web page without reloading the whole page. The main purpose of Ajax is to provide a simple and standard means for a web page to communicate with the server without a complete page refresh. Ans: AJAX(Asynchronous JavaScript And XML(AJAX) )is not a new programming language, but a new way to use existing standards. AJAX is the art of exchanging data with a server, and update parts of a web page without reloading the whole page. The main purpose of Ajax is to provide a simple and standard means for a web page to communicate with the server without a complete page refresh. Ques: 2 How to create an AJAX website using Visual Studio? Ans: 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. If using Visual Studio 2008 Web Developer Express Ajax comes along with it (so no need of a separate installation).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). Ques: 3 What is the ASP.NET Ajax Framework? Ans: 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. Ques: 4 What role does the ScriptManager play? Ans: The ScriptManager manages all ASP.NET AJAX resources on a page and renders the links for the ASP.NET AJAX client libraries, which lets you use AJAX functionality like PageMethods, UpdatePanels etc. It creates the PageRequestManager and Application objects, which are prominent in raising events during the client life cycle of an ASP.NET AJAX Web page. It also helps you create proxies to call web services asynchronously. The ScriptManager control (that we may drag on a web form) is actually an instance of the ScriptManager class that we put on a web page. The ScriptManager manages all the ASP.NET Ajax controls on a web page. Using ScriptManager class: 1 - All resources managing on a web page. 2 - Partial page updates 3 - Interact with UpdatePanel Control.

4 - Information Release whether. 5 - Provied Facility to access Web Services Method 6 - Providing access to ASP.NET authentication role. Ques: 5 What are limitations of Ajax? Ans: 1.If the network bandwidth is slow,end user confused because no page postback full running. 2.Distributed applications running Ajax will need a central mechanism for communicating with each other Ques: 6 What is the role of a ScriptManagerProxy? Ans: In case of Master page scenario in your application and the MasterPage contains a ScriptManager control, then you can use the ScriptManagerProxy control to add scripts to content pages.A page can contain only one ScriptManager control. Also, if you come across a scenario where only a few pages in your application need to register to a script or a web service, then its best to remove them from the ScriptManager control and add them to individual pages, by using the ScriptManagerProxy control. That is because if you added the scripts using the ScriptManager on the Master Page, then these items will be downloaded on each page that derives from the MasterPage, even if they are not needed, which would lead to a waste of resources. Ques: 7 What is an UpdatePanel Control? Ans: All controls residing inside the UpdatePanel will be partial postbacked.An UpdatePanel control is a holder for server side controls that need to be partial postbacked in an ajax cycle.The UpdatePanel enables you to add AJAX functionality to existing ASP.NET applications. It can be used to update content in a page by using Partial-page rendering. By using Partial-page rendering, you can refresh only a selected part of the page instead of refreshing the whole page with a postback. Ques: 8 What is the name of AJAX controls ? Ans: There are 5 AJAX controls. 1. ScriptManager 2. UpdatePanel 3. UpdateProgress 4. Timer 5. ScriptManageProxy Ques: 9 What is ASP.NET AJAX? Ans: ASP.NET AJAX is a terminology by Microsoft for implementation of AJAX, which is a set of extensions to ASP.NET. These components allow you to build rich AJAX enabled web applications, which consists of both server side and client side libraries. Ques: 10 Define Internet Standards for AJAX? Ans: AJAX is based on internet standards, and uses a combination of: 1. XMLHttpRequest object (to exchange data asynchronously with a server) 2. JavaScript/DOM (to display/interact with the information) 3. CSS (to style the data) 4. XML (often used as the format for transferring data) Ques: 11 What is XMLHttpRequest object in AJAX? Ans: The XMLHttpRequest object is used to exchange data with a server. With the XMLHttpRequest object Browser can retrieve and submit XML data directly to a

Web server without reloading the page. To convert XML data into renderable HTML content, use the client-side Extensible Stylesheet Language Transformations (XSLT) to compose HTML elements for presentation. Property: 1. Onreadystatechange 2. readyState 3. responseBody 4. responseTextresponseXML 5. StatusstatusText Method 1. abort 2. getAllResponseHeaders: 3. getResponseHeader 4. open 5. send Ques: 12 Why Use ASP.NET AJAX Features? Ans: Features: 1. Improved efficiency. 2. As user requirement significant parts of a Web page's processing are performed in the browser. 3. UI elements- progress indicators, tool tips, and pop-up windows. 4. Partial-page updates that refresh only the parts of the Web page that have changed. 5. Client integration with ASP.NET application services for forms authentication, roles, and user profiles. 6. Auto-generated proxy classes. 7. Provide a framework that lets you customize of server controls to include client capabilities. Ques: 13 Define ASP.NET AJAX Client Life-Cycle Events? Ans: The two main Microsoft AJAX Library classes that raise events during the client life cycle of a page: 1. Application and 2. PageRequestManager classes. When partial-page rendering with UpdatePanel controls is enabled, the key client events are the events of the PageRequestManager class. These events enable you to handle many common scenarios. These include the ability to cancel postbacks, to give precedence to one postback over another, and to animate UpdatePanel controls when their content is refreshed. 1. Sys.WebForms.PageRequestManager Events: initializeRequest: Raised during initialization of an asynchronous postback. beginRequest: Raised before processing of an asynchronous postback starts, pageLoading: Raised after a response to an asynchronous postback is received from the server, but before any content on the page is updated. pageLoaded: Raised after all content on the page is refreshed as the result of either a synchronous or an asynchronous postback. endRequest: Use this event to provide customized error notification to users or to log errors. 2. Sys.Application Events:

init: Raised only once when the page is first rendered after all scripts have been loaded, but before objects are created. load: Raised after all scripts have been loaded and objects in the application have been created and initialized. unload: Raised before all objects in the client application are disposed. Ques: 14 How to Check Whether AJAX Functionality is Enabled for a Page? Ans: Use the following code to determine whether AJAX functionality is enabled for a page in C# Code: ScriptManager sm = ScriptManager.GetCurrent(Page) if (sm == null) { // ASP.NET AJAX functionality is not enabled for the page. } else { // AJAX functionality is enabled for the page. } To determine whether partial page rendering is supported for a page, you can modify this code to use the EnablePartialRendering and the SupportsPartialRendering property of the ScriptManager control. Ques: 15 How to Add an AJAX Extender Control? Ans: The ASP.NET AJAX Control Toolkit includes several extender controls that can be used to enhance the client functionality of Web server controls. Before you add an extender control to a server control in the following procedure, you must install the ASP.NET AJAX Toolkit. You can download the Control Toolkit from the ASP.NET AJAX Control Toolkit Web site. 1.Switch to Design view. 2.If the page does not already contain a ScriptManager control, from the AJAX Extensions tab of the Toolbox, drag one onto the page. 3.From the Standard tab of the Toolbox, drag a Button control onto the page. 4.If the Common Button Tasks shortcut menu does not appear, right-click the Button control and then click Show Smart Tag. 5.On the Common Button Tasks menu, click Add Extender. 6.In the Extender Wizard, in the Choose the functionality to add to Button1 list, click ConfirmButtonExtender, and then click OK. 7.In the Properties window, expand the Extenders tab, and then expand Button1_ConfirmButtonExtender. 8.Set the ConfirmText property to Continue? Ques: 16 How to Remove an AJAX Extender Control in ASP.NET? Ans: If the functionality of an extender control is no longer needed, you can remove the extender control. 1.Switch to Design view. 2.Select the Button control, and then on the Common Button Tasks menu, click Remove Extender. 3.In the Extenders attached to Button1 list, select ConfirmButtonExtender. 4.Click Remove, and then click OK. Ques: 17 What is the ASP.NET AJAX Extender Controls? Ans: If you want to adds client functionality to a Button control when users confirm to submit a form to the server then extender controls can use. ASP.NET AJAX extender controls enhance the client capabilities of standard

ASP.NET Web server controls such as TextBox controls, Button controls, and Panel controls by using one or more extender controls to provide a richer user experience in the browser, and you also add ASP.NET AJAX extender controls to Visual Studio and work with them as you do with other controls. You can create your own extender controls and source for extender controls is the ASP.NET AJAX Control Toolkit. Ques: 18 What are the features of ASP.NET AJAX Extender Controls Ans: Visual Studio supports the following extender control features: 1.Adding extender controls. 2.Removing extender controls. 3.Setting extender control properties. 4.Managing extender controls Ques: 19 List of all Extender Controls in the AJAX Control Toolktit? Ans: Extender Controls in the AJAX Control Toolktit: 1.CascadingDropDown 2.CollapsiblePanelExtender 3.ConfirmButtonExtender 4.FilteredTextBoxExtender 5.ModalPopupExtender 6.PasswordStrength 7.RoundedCornersExtender 8.TextBoxWatermarkExtender Ques: 20 Define Classes in ASP.NET AJAX Extender Controls? Ans: Two classes: 1.ExtenderControl: The ExtenderControl class enabled to programmatically add AJAX functionality to an ASP.NET server control and inherits from the Control class and implements the IExtenderControl interface. The Control class defines the properties, methods, and events that are shared by all ASP.NET server controls. Inheritance Hierarchy: System.Object System.Web.UI..::.Control System.Web.UI.ExtenderControl 2.IExtenderControl: The ExtenderControl base class performs an explicit test to make sure that a ScriptManager control exists on the page. However, if you want to create extender controls and the page does not contain an ScriptManager control, you can create a class that implements the IExtenderControl interface directly. Inheritance Hierarchy: System.Object System.Web.UI.Control System.Web.UI.IExtenderControl

Ajax Interview Questions And Answers

Page 1
Ques: 1 How to Globalize and Localize client script files in AJAX ASP.NET?

Ans: The ScriptManager control enables you to globalize and localize client script files. Globalization lets you use the Date and Number JavaScript type extensions in your script and have those objects display values that are based on the current culture. Localization lets you provide client script files for different cultures. Ques: 2 How to raise a PropertyChanged Event in AJAX ASP.NET? Ans: Invoking to the Sys.Component raisePropertyChanged method in a property set accessor to raise a propertyChanged event. Your component inherits the raisePropertyChanged method from the Sys.Component, Sys.UI.Behavior, or Sys.UI.Control base class. The following example shows how to raise a propertyChanged event for an interval property whenever the property is set. get_interval: function() { return this._interval; }, set_interval: function(value) { if (this._interval !== value) { this._interval = value; this.raisePropertyChanged('interval'); } } Ques: 3 Defining Public Properties in a Custom Client Component in AJAX ASP.NET? Ans: In ASP.NET AJAXclient components, property accessors are defined as methods of the class prototype. The accessor methods are named with get_ and set_ prefixes followed by the property name. The following example shows how to define a read-write property named interval in the class prototype. get_interval: function() { return this._interval; }, set_interval: function(value) { this._interval = value; } Ques: 4 What is Custom Component Properties in AJAX ASP.NET? Ans: When creating a client component class, define the properties that expected page developers to access. Also raise Sys.Component.propertyChanged notification events in the set accessors for properties of your component. Page developers who use the component can bind the property notification event to their own handler to run code when the property value changes. Ques: 5 How to use a Timer Control outside an UpdatePanel Control in AJAX ASP.NET? Ans: : If the Timer controls are outside an UpdatePanel control, the JavaScript timing component continues to run as the postback is being processed. For example, if the Interval property is set to 60,000 milliseconds (60 seconds)

and the postback takes 3 seconds to complete, the next postback will occur 60 seconds after the previous postback. The user will see the refreshed content in the UpdatePanel control for only 57 seconds. The following example shows how to use the Timer control outside an UpdatePanel control: <asp:ScriptManager runat="server" id="ScriptManager1" /> <asp:Timer ID="Timer1" runat="server" Interval="120000" OnTick="Timer1_Tick"> </asp:Timer> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers> <ContentTemplate> <asp:Label ID="Label1" runat="server" ></asp:Label> </ContentTemplate> </asp:UpdatePanel> Ques: 6 How to use a Timer Control inside an UpdatePanel Control in AJAX ASP.NET? Ans: For Timer controls inside an UpdatePanel control, the JavaScript timing component is re-created only when each postback finishes. Therefore, the timed interval does not start until the page returns from the postback. For instance, if the Interval property is set to 60,000 milliseconds (60 seconds) but the postback takes 3 seconds to complete, the next postback will occur 63 seconds after the previous postback. When the Timer control is included inside an UpdatePanel control, the Timer control automatically works as a trigger for the UpdatePanel control. The following example shows how to include a Timer control inside an UpdatePanel control: <asp:ScriptManager runat="server" id="ScriptManager1" /> <asp:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="Conditional"> <contenttemplate> <asp:Timer id="Timer1" runat="server" Interval="120000" OnTick="Timer1_Tick"> </asp:Timer> </contenttemplate> </asp:UpdatePanel> Ans: For Timer controls inside an UpdatePanel control, the JavaScript timing component is re-created only when each postback finishes. Therefore, the timed interval does not start until the page returns from the postback. For instance, if the Interval property is set to 60,000 milliseconds (60 seconds) but the postback takes 3 seconds to complete, the next postback will occur 63 seconds after the previous postback. When the Timer control is included inside an UpdatePanel control, the Timer control automatically works as a trigger for the UpdatePanel control. The following example shows how to include a Timer control inside an UpdatePanel control: <asp:ScriptManager runat="server" id="ScriptManager1" /> <asp:UpdatePanel runat="server" id="UpdatePanel1" UpdateMode="Conditional"> <contenttemplate>

<asp:Timer id="Timer1" runat="server" Interval="120000" OnTick="Timer1_Tick"> </asp:Timer> </contenttemplate> </asp:UpdatePanel> Ques: 7 What is Timer control in AJAX ASP.NET? Ans: The ASP.NET AJAX Timer control performs postbacks at defined intervals. If Timer control used with an UpdatePanel control, you can enable partial-page updates at a defined interval. You can also use the Timer control to post the whole page. You use the Timer control when you want to do the following: 1. Periodically update the contents of one or more UpdatePanel controls without refreshing the whole Web page. 2. Run code on the server every time that a Timer control causes a postback. 3. Synchronously post the whole Web page to the Web server at defined intervals Ques: 8 What is AJAX Server Controls in ASP.NET? Ans: ASP.NET Web server controls that enable you to add AJAX functionality to an ASP.NET Web page. AJAX functionality includes refreshing parts of a page with a partial-page update and therefore avoiding a full-page postback. 1. ScriptManager Control Overview: Manages client script for AJAX-enabled ASP.NET pages 2. Timer Control Overview: Performs postbacks at defined intervals. 3. UpdatePanel Control Overview: Enables you to refresh selected parts of the page instead of refreshing the whole page with a postback. 4. UpdateProgress Control Overview: Enables you to provide status information about partial-page updates in UpdatePanel controls. Ques: 9 What is the Debug Helper Classes in AJAX ASP.NET? Ans: ASP.NET provides the Sys.Debug class for debugging client applications. By calling methods of the Sys.Debug class, you can display objects in readable form at the end of the page, show trace messages, use assertions, and break into the debugger. The following table lists the methods of the Sys.Debug class. Sys.Debug.assert(condition, message, displayCaller): Checks for a condition, and if the condition is false, displays a message and prompts the user to break into the debugger. Sys.Debug.clearTrace(): Clears all trace messages from the TraceConsoletextarea element. Sys.Debug.traceDump(object, name): Dumps an object to the debugger console and to the TraceConsoletextarea element, if available. Sys.Debug.fail(message):

Displays a message in the debugger's output window and breaks into the debugger. Sys.Debug.trace(text): Appends a text line to the debugger console and to the TraceConsoletextarea element, if available. Ques: 10 Define Classes in ASP.NET AJAX Extender Controls? Ans: Two classes: 1.ExtenderControl: The ExtenderControl class enabled to programmatically add AJAX functionality to an ASP.NET server control and inherits from the Control class and implements the IExtenderControl interface. The Control class defines the properties, methods, and events that are shared by all ASP.NET server controls. Inheritance Hierarchy: System.Object System.Web.UI..::.Control System.Web.UI.ExtenderControl 2.IExtenderControl: The ExtenderControl base class performs an explicit test to make sure that a ScriptManager control exists on the page. However, if you want to create extender controls and the page does not contain an ScriptManager control, you can create a class that implements the IExtenderControl interface directly. Inheritance Hierarchy: System.Object System.Web.UI.Control System.Web.UI.IExtenderControl Ques: 11 List of all Extender Controls in the AJAX Control Toolktit? Ans: Extender Controls in the AJAX Control Toolktit: 1.CascadingDropDown 2.CollapsiblePanelExtender 3.ConfirmButtonExtender 4.FilteredTextBoxExtender 5.ModalPopupExtender 6.PasswordStrength 7.RoundedCornersExtender 8.TextBoxWatermarkExtender Ques: 12 What are the features of ASP.NET AJAX Extender Controls Ans: Visual Studio supports the following extender control features: 1.Adding extender controls. 2.Removing extender controls. 3.Setting extender control properties. 4.Managing extender controls Ques: 13 What is the ASP.NET AJAX Extender Controls? Ans: If you want to adds client functionality to a Button control when users confirm to submit a form to the server then extender controls can use. ASP.NET AJAX extender controls enhance the client capabilities of standard ASP.NET Web server controls such as TextBox controls, Button controls, and Panel controls by using one or more extender controls to provide a richer

user experience in the browser, and you also add ASP.NET AJAX extender controls to Visual Studio and work with them as you do with other controls. You can create your own extender controls and source for extender controls is the ASP.NET AJAX Control Toolkit. Ques: 14 How to Remove an AJAX Extender Control in ASP.NET? Ans: If the functionality of an extender control is no longer needed, you can remove the extender control. 1.Switch to Design view. 2.Select the Button control, and then on the Common Button Tasks menu, click Remove Extender. 3.In the Extenders attached to Button1 list, select ConfirmButtonExtender. 4.Click Remove, and then click OK. Ques: 15 How to Add an AJAX Extender Control? Ans: The ASP.NET AJAX Control Toolkit includes several extender controls that can be used to enhance the client functionality of Web server controls. Before you add an extender control to a server control in the following procedure, you must install the ASP.NET AJAX Toolkit. You can download the Control Toolkit from the ASP.NET AJAX Control Toolkit Web site. 1.Switch to Design view. 2.If the page does not already contain a ScriptManager control, from the AJAX Extensions tab of the Toolbox, drag one onto the page. 3.From the Standard tab of the Toolbox, drag a Button control onto the page. 4.If the Common Button Tasks shortcut menu does not appear, right-click the Button control and then click Show Smart Tag. 5.On the Common Button Tasks menu, click Add Extender. 6.In the Extender Wizard, in the Choose the functionality to add to Button1 list, click ConfirmButtonExtender, and then click OK. 7.In the Properties window, expand the Extenders tab, and then expand Button1_ConfirmButtonExtender. 8.Set the ConfirmText property to Continue? Ques: 16 How to Check Whether AJAX Functionality is Enabled for a Page? Ans: Use the following code to determine whether AJAX functionality is enabled for a page in C# Code: ScriptManager sm = ScriptManager.GetCurrent(Page) if (sm == null) { // ASP.NET AJAX functionality is not enabled for the page. } else { // AJAX functionality is enabled for the page. } To determine whether partial page rendering is supported for a page, you can modify this code to use the EnablePartialRendering and the SupportsPartialRendering property of the ScriptManager control. Ques: 17 Define ASP.NET AJAX Client Life-Cycle Events? Ans: The two main Microsoft AJAX Library classes that raise events during the client life cycle of a page: 1. Application and 2. PageRequestManager classes.

When partial-page rendering with UpdatePanel controls is enabled, the key client events are the events of the PageRequestManager class. These events enable you to handle many common scenarios. These include the ability to cancel postbacks, to give precedence to one postback over another, and to animate UpdatePanel controls when their content is refreshed. 1. Sys.WebForms.PageRequestManager Events: initializeRequest: Raised during initialization of an asynchronous postback. beginRequest: Raised before processing of an asynchronous postback starts, pageLoading: Raised after a response to an asynchronous postback is received from the server, but before any content on the page is updated. pageLoaded: Raised after all content on the page is refreshed as the result of either a synchronous or an asynchronous postback. endRequest: Use this event to provide customized error notification to users or to log errors. 2. Sys.Application Events: init: Raised only once when the page is first rendered after all scripts have been loaded, but before objects are created. load: Raised after all scripts have been loaded and objects in the application have been created and initialized. unload: Raised before all objects in the client application are disposed. Ques: 18 Why Use ASP.NET AJAX Features? Ans: Features: 1. Improved efficiency. 2. As user requirement significant parts of a Web page's processing are performed in the browser. 3. UI elements- progress indicators, tool tips, and pop-up windows. 4. Partial-page updates that refresh only the parts of the Web page that have changed. 5. Client integration with ASP.NET application services for forms authentication, roles, and user profiles. 6. Auto-generated proxy classes. 7. Provide a framework that lets you customize of server controls to include client capabilities. Ques: 19 What is XMLHttpRequest object in AJAX? Ans: The XMLHttpRequest object is used to exchange data with a server. With the XMLHttpRequest object Browser can retrieve and submit XML data directly to a Web server without reloading the page. To convert XML data into renderable HTML content, use the client-side Extensible Stylesheet Language Transformations (XSLT) to compose HTML elements for presentation. Property: 1. Onreadystatechange 2. readyState 3. responseBody 4. responseTextresponseXML 5. StatusstatusText Method 1. abort 2. getAllResponseHeaders:

3. getResponseHeader 4. open 5. send Ques: 20 Define Internet Standards for AJAX? Ans: AJAX is based on internet standards, and uses a combination of: 1. XMLHttpRequest object (to exchange data asynchronously with a server) 2. JavaScript/DOM (to display/interact with the information) 3. CSS (to style the data) 4. XML (often used as the format for transferring data)

Você também pode gostar