Monday 30 March 2015

Visual Studio - Add JQuery Intellisense to ASP.NET Pages

There are multiple ways to enable intellisense for JQuery in Visual Studio.
I will lay down the steps for one of the methods.
  1. Add reference to the JQuery file.
    • <script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.11.2.min.js"></script>
  2. Install the nuget package:
    • https://www.nuget.org/packages/jQuery-vsdoc/
    • This will add reference to the required js files to enable intellisense along with documentation for the intellisense.
    • By default, the nuget package manager will add the files to /Scripts/......
  3. Add reference to the above js files on your web page. There are multiple files in the Scripts folder, But only the one below is necessary. 
    • <% if (false){ %>
      <script src="Scripts/jquery-2.1.0-vsdoc.js"></script>
      <% } %>
    • As you see the script is added within server side code, with an if condition set to false.
    • This makes sure the vsdoc file (that enables intellisense) is not rendered to the client.
Following the above steps have enabled JQuery Intellisense on your webpage.

Happy Coding.

No comments:

Post a Comment