How to get javascript intellisense for Asp.NET AJAX in a usercontrol (ascx) file

To get javascript intellisense for jQuery and your own scripts inside a usercontrol file you can use the following hack at the top of the ascx-file (after the @Control directive).

<% if (false) { %>
    <script src="scripts/jquery-1.3.2.js" type="text/javascript"></script>
    <script src="scripts/myScripts.js" type="text/javascript"></script>
<% } %>

This simply means that when you work with the file in Visual Studio, it will give you intellisense for these javascript libraries. But in runtime the if statement will be false so the scripts will not be included again (they shouldn't because they should already be included by the page that hosts the usercontrol. Remember, this hack is for Visual Studio javascript intellisense only).

But what about the Asp.NET AJAX framework (whit the $get, $addHandler methods etc...)? One workaround I figured out is to follow these steps:

  1. Load an .aspx page that contains a ScriptManager in your browser.
  2. View the source and copy out the src for a script tag that contains "ScriptResource.axd" (marked text in this image):
  3. Paste this after localhost:port in the address field of the browser so that the script file loads (I only got this to work in Firefox):
  4. If it starts with the comment in the image above, go on to the next step, if not return to step number two and get the next reference that includes "ScriptResource.axd".
  5. Once you've found the MicrosoftAjax.debug.js file, copy the entire contents, paste it into a .js-file and put it in your project.
  6. Now you can reference that file from your ascx file and get intellisense for Asp.NET AJAX even in a usercontrol file: image

Finally, an appropriate quote: "Oh the troubles we put ourselves through for pretty IntelliSense.".