AJAX.net Questions and Answers

Posted by in ASP.NET AJAX category on for Intermediate level | Views : 10814 red flag

This article describes some ASP.NET Ajax commonly asked questions and answers.
What is the role of ScriptManager in Ajax?
The ScriptManager control manages client script for Microsoft ASP.NET AJAX pages. By default, the ScriptManager control registers the script for the Microsoft AJAX Library with the page. This enables client script to use the type system extensions and to support features such as partial-page rendering and Web-service calls.

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)

What are the steps required and are necessary to make a normal website, an AJAX enable web site?
1. <configSections>
<sectionGroup name="system.web.extensions" ………
<sectionGroup name="scripting" …………
<section name="scriptResourceHandler" ………
<sectionGroup name="webServices" ………..
<section name="jsonSerialization" …………….
<section name="profileService" ………………….
<section name="authenticationService" ……………

2. <httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>

3. <httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

4. <compilation debug="true">
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

Which class and method of Sys.Net namespace do we use to make an Asynchronous request in JAVASCRIPT?
Sys.Net.WebRequest class
And invoke method

What is the order of PageRequestManager class events ,when a single asynchronous AJAX request is made?

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.

What are the modes of updation in an UpdatePanel? What are Triggers of an UpdatePanel?
An UpdatePanel has a property called UpdateMode. There are two possible values for this property: 1) Always 2) Conditional

What is ChildrenAsTriggers ,and to which control it belongs?
When the ChildrenAsTriggers property is set to true and any child control of the UpdatePanel control causes a postback. Child controls of nested UpdatePanel controls do not cause an update to the outer UpdatePanel control unless they are explicitly defined as triggers for the parent panel.

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 <asp:ScriptManager id="ScriptManager1" runat="server" AsyncPostBackTimeout="9000"/>

Is there any control to show the status of an asynchronous request? If yes, name it?
Yes, UpdateProgress

How do you invoke a web method of web service in AJAX?
In order to use a webmethod of a webservice, we need to add the reference of webservice in the <services> section of ScriptManager. Under services you have to configure the servicepath.

<asp:ScriptManager ID="ScriptManager1" runat="server">
<asp:ServiceReference Path="..\service1.asmx" />
Inside JAvascript Use methods of this service directly like

How will you invoke a web method in AJAX?
Set EnablePageMethods property of ScriptManager to "true"
And inside Javascript we can directly use

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Aniemsh Misra
Member Level: Starter
Member Status: Member
Member Since: 6/24/2007 11:43:19 PM
Country: India

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)