Thursday, July 13, 2006

Stepping through ATLAS Javascript files

I'm trying to debug an application I'm writing using ATLAS, and I'm wnating to know why my attempts to make browser client magic happen are resulting in java script errors. Fortunately Visual Studio provides a level of debugging for java script files which means that if you're in debug mode when a java script error occurs, you'll automatically be taken to the point in the code where the problem occured and given some useful things like a stack trace and a variable watch window. You can also set break points in your own code, however, if you have registered the scriptsw using an Atlas Script manager as is advised when writing ASP.Net applications


<atlas:ScriptManager ID="ScriptManager1" runat="server" >
<Scripts>
<atlas:ScriptReference ScriptName="AtlasUIDragDrop" />
</Scripts>
</atlas:ScriptManager>


you will not be able step into any of the ATLAS libraries you happen to be using as the debugger complains that the source files are not available. This is because of the way the ATLAS scrip manager embeds the java script.

today I found myself thinking that it would be handy to be able to step into these files to find out what's going on prior to the error.

To solve the problem

  1. Copy the necessary java script files from the install location into your project and mark them as "Embedded Resource". In my case Atlas.js and AtlasUIDragDrop.js

  2. Comment out or remove the Atlas Script Manager component

  3. Add the script files as you would add any normal java script file (ie with the <script> tag)



Once you have done this you should be able to step into the ATLAS java script files to your hearts content, but be warned you might find it a little scarey in there.

The only problem with this is that it won't work for Server Side Atlas controls, such as UpdatePanel or Extender controls, but if you're not using them, or if you can comment them out while you debug stuff, then you're set.

No comments:

Post a Comment