Add jQuery in visual web part in SharePoint 2010/2013/2016

This SharePoint tutorial, we will discuss, how to give jQuery reference in a visual web part in SharePoint 2010/2013/2016.

In my previous tutorial, I have explained, How to Deploy jQuery files to SharePoint using Solution Package in SharePoint 2010/2013/2016.

Add jQuery in a visual web part in SharePoint

Follow the below steps to add jQuery in a visual web part in SharePoint. The screenshots are from visual studio 2010, but it will work the same way in SharePoint 2013/2016.

Step-1:
Open Visual Studio 2010, Click on File -> New project. Then from the New Project dialog box, select Visual C# -> SharePoint -> 2010.

Then from the list of SharePoint 2010, project templates select the Empty SharePoint Project. Give a name and make sure .net Framework 3.5 is selected as shown in the figure below:

add jQuery in visual web part in SharePoint

Step-2:
In the next step Give a local site for debugging and Select Deploy as a farm solution and click on Finish as shown in the figure below:

add jquery in sharepoint

Step-3:
Now Right-click on the project -> Add -> New Item

Then from the list of installed templates Select Visual Web Part, Give a name and click on Add as shown in the figure below:

sharepoint 2013 add jquery

Step-4:
Now open the .ascx file and add the following script:

<script type="text/javascript" src="http://siteURL/_layouts/jQuery/jquery-min-1.6.js"></script>

After that deploy the web part. The jQuery will be available to those pages where you will add the web part.

You may like following SharePoint visual web part tutorials:

This SharePoint tutorial, we learned how to add jQuery in a visual web part in SharePoint 2010/2013/2016.

free sharepoint training

SharePoint Online FREE Training

JOIN a FREE SharePoint Video Course (3 Part Video Series)

envelope
envelope

Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site SharePointSky.com

>