[英]Is there any way to get Intellisense working in Visual Studio / MVC without the “if(false)” hack?
Other than the "if(false)" hack, is there any way to get Intellisense working in VS 2010 / MVC when using the server-side Url.Content() method for re-basing Javascript files? 除了使用“ if(false)” hack之外,当使用服务器端Url.Content()方法重新对Javascript文件进行基础处理时,还有什么方法可以使Intellisense在VS 2010 / MVC中工作?
Master Page: 母版页:
<script src="<%=Url.Content("~/Scripts/jquery-1.4.2.js") %>" type="text/javascript"></script>
I know about the if(false) hack but I was hoping there way a more elegant solution. 我知道if(false)骇客,但我希望有一个更优雅的解决方案。
if(false) hack: if(false)hack:
<% if (false){ %>
<script type="text/javascript" src="../Scripts/jquery-1.4.2.js"></script>
<% } %>
Does Microsoft have any plans to address this issue in future releases of VS? Microsoft是否有计划在VS的将来版本中解决此问题?
I find the best approach is to keep your JavaScript in separate files, particularly when you're working mostly event driven with jQuery. 我发现最好的方法是将JavaScript保留在单独的文件中,尤其是当您主要使用jQuery驱动事件驱动时。 That way you can reference your related files to get full intellisense support and get all the browser-caching advantages that come with this approach. 这样,您可以引用相关文件以获得完整的智能感知支持并获得此方法附带的所有浏览器缓存优势。
you can drag the .js file from solution explorer to code window which generates the following line: /// <reference path="jquery-1.4.1-vsdoc.js" />
it works well in custom JS files that rely on other JS files (in my case jquery is included in the master page). 您可以将.js文件从解决方案资源管理器拖到代码窗口,该代码窗口会生成以下行: /// <reference path="jquery-1.4.1-vsdoc.js" />
可以在依赖于其他文件的自定义JS文件中很好地工作JS文件(在我的情况下,jquery包含在母版页中)。
If you are having trouble in the aspx content files - I am using T4MVC; 如果您在aspx内容文件中遇到问题-我使用的是T4MVC; I have <script src="<%: Links.Scripts.jquery_1_4_1_js %>" type="text/javascript"></script>
and I get Intellisense there as well... 我有<script src="<%: Links.Scripts.jquery_1_4_1_js %>" type="text/javascript"></script>
,我在那里也得到了Intellisense ...
我想即使是Visual Studio的Intellisense也不能接受汤标签 :-)并不能真正回答您的问题,但是您可以使用MVCContrib :
<%= Html.ScriptInclude("~/scripts/jquery-1.4.2.js") %>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.