How do you work with jQuery intellisense if you have implemented the Url Helper extension to get the URL of your script files?

I implemented the Url Helper extensions that Kazi Manzur suggested in his MVC best practice guide here

My extended Url extension method to get the script file:

public const string ScriptDir = "~/Assets/Scripts";
public static string Script(this UrlHelper helper, string fileName)
{
    return helper.Content(string.Format("{0}/{1}", ScriptDir, fileName));
}

And on my main page, I just add a jQuery script to my page like this:

<script type="text/javascript" src="<%= Url.Script("jquery-1.3.2.min.js") %>"></script>

How do I get intellisense working for jQuery since Visual Studio does not know at design time that jquery-1.3.2.min.js is included in the main page?

The workaround that I currently include is the following code (hardcode my -vsdoc script location) on my main page. This might be the best solution at the moment:

<% if (false) { %> <script type="text/javascript" src="~/Assets/Scripts/jquery-1.3.2-vsdoc.js"></script> <% } %>
+3
3

-vsdoc . vsdoc intellisense . , - , intellisense jquery script. .ascx, , intellisense.

, , , "-vsdoc":

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

, , . - .


, . :

<% #if (false) %>
    <script src="../../Content/scripts/jquery-1.3.2.js" type="text/javascript"></script> 
<% #endif %>
+9

URL- , . (.. ).

, , , . Intellisense , 100%.

+1

Source: https://habr.com/ru/post/1706775/


All Articles