Saturday, August 6, 2011

ASP.NET Ajax Extension Script Manager

In order to use ASP.NET AJAX you need to add ScriptManager to your webpage. This control is the brain of ASP.NET AJAX.

You can add it from ToolBox tabnamed AJAX Extensions. The source of this control is as below:

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

This control add links to ASP.NET AJAX libraries in your page. The output of this looks something like:

< Script src="/YourWebSite/ScriptResource.axd?d=RUSU1mI......" type="text/javascript" >< /Script >

It brings the JavaScript code using 'src' attribute. Rather than adding extra javascript files, the src attribute points to ScriptResource.axd. ScriptResource.axd is not an actual file. It tells ASP.NET to find Javascript file in one of the compiled .Net assemblies. The query string arguments tells ScriptResource.axd extension the file to be sent to the browser.

Every page that uses ASP.NET AJAX requires an instance of the ScriptManager. However, you can only use one ScriptManager on a page. ASP.NET AJAX-enabled controls can interact with the ScriptManager, directing it to link to additional Javascript files.

It's recommended that you add ScriptManager to master pages of the website. However, different content pages may require different settings of the properties of ScriptManager. The solution to this requirement is to add ScriptManager to master page and then add ScriptManagerProxy to the content pages. This ScriptManagerProxy can be configured in the same way as ScriptManager on the page.


The Javascript files used by ASP.NET AJAX contains thousands of complex lines that forms the bases of all Ajax functionalities. These files are ver compant not more than 200 KB, depending on the features being used on the page. This code is downloaded only once and then cached by the browser for later use. Also ASP.NET sends a compressed version of script in case the browser supports it. Thus Ajax enabled web pages do not require a longer download time.

How to Ajax



No comments:

Post a Comment