Maxim Gershkovich
Maxim Gershkovich

Reputation: 47189

Javascript Intellisense in ASP.Net Usercontrols

As you will all probably be aware you can reference external Javascript files in Visual Studio 2010 using the following directive.

/// <reference path="MyExternalFile.js" />

Great!

Directives to external Javascript files that exist in masterpages are automatically transferred to content pages. Again great!

However how can you create a reference to a javascript file inside an ASP.Net usercontrol when the javascript file is declared in a masterpage?

I assume (although untested) that a scriptmanagerproxy would accomplish this. However I do not use a script manager in my web app.

Is there an alternative similar to what I display above for use in a UserControl?

Upvotes: 5

Views: 333

Answers (1)

Martin Buberl
Martin Buberl

Reputation: 47164

It's a bit ugly but you could reference a JavaScript file just for the user control without rendering it:

<% if (false) { %>
<script src="../scripts/jquery-1.4.1-vsdoc.js"></script>
<% } %>

This way Visual Studio will give you Intellisense:

enter image description here

Upvotes: 3

Related Questions