As you will all probably be aware you can reference external Javascript files in Visual Studio 2010 using the following directive.
您可能都知道,您可以使用以下指令在Visual Studio 2010中引用外部Javascript文件。
/// <reference path="MyExternalFile.js" />
Great!
大!
Directives to external Javascript files that exist in masterpages are automatically transferred to content pages. Again great!
对主页中存在的外部Javascript文件的指令会自动转移到内容页面。再好啊!
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?
但是,当在主页中声明javascript文件时,如何在ASP.Net用户控件内创建对javascript文件的引用?
I assume (although untested) that a scriptmanagerproxy would accomplish this. However I do not use a script manager in my web app.
我假设(尽管未经测试)scriptmanagerproxy将实现此目的。但是,我不在我的Web应用程序中使用脚本管理器。
Is there an alternative similar to what I display above for use in a UserControl?
是否有类似于我在上面显示的用于UserControl的替代方法?
1 个解决方案
#1
3
It's a bit ugly but you could reference a JavaScript file just for the user control without rendering it:
它有点难看,但你可以引用一个JavaScript文件,只是为了用户控件而不渲染它:
<% if (false) { %>
<script src="../scripts/jquery-1.4.1-vsdoc.js"></script>
<% } %>
This way Visual Studio will give you Intellisense:
这样Visual Studio将为您提供Intellisense:
#1
3
It's a bit ugly but you could reference a JavaScript file just for the user control without rendering it:
它有点难看,但你可以引用一个JavaScript文件,只是为了用户控件而不渲染它:
<% if (false) { %>
<script src="../scripts/jquery-1.4.1-vsdoc.js"></script>
<% } %>
This way Visual Studio will give you Intellisense:
这样Visual Studio将为您提供Intellisense: