Stefan Says

Opinions on ASP.NET, ASP, databases etc
posts - 34, comments - 25, trackbacks - 23

Javascript control article serie

As Ajax is becoming more and more a reality - Javascript management becomes very important for us developers.

 

The ClientScriptManager of the ASP.NET page class sure offers some pretty neat (and not to say easy to use) functions for injecting javascript into your ASP.NET pages. However, if you ask me, there are some problems with it:

1. You typically end up with a lot of <script> tags in a lot of places of your resulting html page. While it might seem like - "who cares" - it sure eases debugging and readability to keep them together. This "<script>-all-around-the-html" thing sure is true if you are using master pages and different aspx files should include different js files.

2. While GetResourceUrl and the automatic AXD handler makes it easy to generate the script path for a embedded javascript - that's pretty much the problem. It needs to be compiled into the dll as an embedded resource (I might be wrong, but I have found to way to using it against a - dynamic- file). I would just like to be able top update the javascript file by editing the js file and copy that file up to my site.

3.More on the GetResourceUrl -  it is a mess to figure out which call references which resource(js file) since the url is changed to a GUID and looks like <script src=''WebResource.axd?d=2xsUS-1nPmr7olmFBqYNkpbyLlXRILCM273mk95wQp37A97mlQ-atvpQwC_7K1uT0&amp;t=633035156331875000"> or whatever...

4. Some way of debug/release mode would be nice - while the AXD handler packs the result when compiled in release mode I would like to have control of that myself - I always have my own web.config appsettings variable - DebugMode (true/false) which I use to turn tuning things on and off. I mean - it is often you need to check something out on the production server - and if you by just setting a variable/sending in an extra query param could get some extra information out it is really invaluable.  

I will continue working on this - but the first steps are solved by using the control I have developed in this article serie on

 Control your Javascript in ASP.NET

Print | posted on Monday, January 08, 2007 11:11 AM