WorldofASP.NET : ASP.NET Tutorial, Hosting, and Source Code
You are 1 of 377 users

Product SpotLight Hosting SpotLight

Using ScriptManager with other frameworks

Blogger : Atlas and more
All posts : All posts by Atlas and more
Category : AJAX
Blogged date : 2008 Jul 08

ScriptManager is a useful control. It manages script references, removes duplicates, enables localization and debug/release modes, enables script combining and makes client-side component-based development easier (components register their script dependencies with ScriptManager without the page developer having to know those dependencies). But one thing we should have anticipated was that this control would be interesting to developers who wish to use a different framework than the Microsoft Ajax Library.

Currently, ScriptManager isn't really usable without Microsoft Ajax because it includes the Microsoft library (without a simple way to disable it) and outputs some startup script to the page. We're looking at correcting that in future versions of the framework, but in the meantime I wanted to come up with a workaround.

The workaround is a simple control derived from ScriptManager and that enables the replacement of the MicrosoftAjax.js reference with a script of your choice:

<%@ Register Namespace="Bleroy" TagPrefix="asp" %>
...
<
asp:AltScriptManager runat="server"
FrameworkPath="~/script/jquery-1.2.6.js" />

Here, we're replacing Microsoft Ajax with jQuery. Being derived from ScriptManager, AltScriptManager benefits from all its features. It just removes the Microsoft Ajax stuff. The resulting markup is:

<script src="script/jquery-1.2.6.js" type="text/javascript"></script>

The first thing the control does is set the default value for EnablePartialRendering to false. This suppresses the default reference to MicrosoftAjaxWebForms.js.

Then, it registers from Init two empty scripts with the type of the ScriptManager and names "AppInitialize" and "FrameworkLoadedCheck". This is a bit of magic that relies on knowledge of the names and types that ScriptManager uses to register its inline scripts.

Finally, it adds a ScriptReference with the Microsoft Ajax assembly and the "MicrosoftAjax.js" name but with a different path (the value of the new FrameworkPath property). This effectively replaces the Microsoft Ajax script reference with a script of your choice.

This should broaden developer choice in terms of client framework while keeping the great benefits of ScriptManager. Hope that helps.

Download it from here: http://weblogs.asp.net/bleroy/attachment/6374028.ashx


Read comments or post a reply to : Using ScriptManager with other frameworks
Page 116 of 1589
Next | Last

.NET News Categories








Legend : - Within 3 Days - Within 6 Days - Within 9 Days

Home | Add Resources | Sponsored Listings | Advertise with Us | SiteMap 1 | SiteMap 2 Link To Us | Contact Us
© 2002-2008 Worldofasp.net ASP.NET Directory, Hosting and Tutorials | All rights reserved
Our Partners : ASP.NET Web Hosting | Windows Web Hosting | FREE ASP.NET CMS | Phone Card | PHP Directory | Bangkok Hotels |Calling Card