Add jQuery in visual web part in SharePoint 2010

In this article, we will discuss how we can give jQuery reference in a visual web part in SharePoint 2010. You can check my previous articles on Deploy jQuery to assets library, Call jQuery to SharePoint using a custom action, Add script reference dynamically through the code in SharePoint.

If you want to learn SharePoint online then you can Download a FREE PDF on SharePoint online tutorial and Download FREE PDF on HUB site in SharePoint online.


Follow the below steps:
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 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 2010
Add jQuery in visual web part in SharePoint 2010

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 visual web part in SharePoint 2016
Add jQuery in visual web part in SharePoint 2016

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:

Add jQuery in visual web part in SharePoint 2013
Add jQuery in visual web part in SharePoint 2013

Add jQuery in visual web part in SharePoint 2016
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>

Read: SharePoint 2016 Create and Deploy Visual web part using Visual Studio 2015


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

Hope this will be helpful.

Check out Best Alternative to InfoPath -> Try Now

free sharepoint training

SharePoint Online FREE Training

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

envelope
envelope

About 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

View all posts by Bijay Kumar →