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:
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:
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:
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 2016
Now open the .ascx file and add the following 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.
SharePoint Online FREE Training
JOIN a FREE SharePoint Video Course (3 Part Video Series)