Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add jQuery UI to Asp.Net Core VS2017?

I have installed jQuery UI using Bower in VS2017.

When I look in Solution Explorer I can see that the Bower package seem to have been installed but I can't find them in the wwwroot folder so I don't know how to add them to the _layout.cshtml file.

What is the procedure for adding jQuery UI to my ASP.NET Core v2 application.

enter image description here

enter image description here

like image 501
Thomas Adrian Avatar asked Jan 26 '18 07:01

Thomas Adrian


People also ask

Can we use jQuery in ASP NET?

To begin with using jQuery with ASP.NET, first download the latest version the jQuery library from jQuery website and unzip or copy the file in your project or Visual studio solution. Microsoft Visual studio 2010 and 2012 include jQuery by default and provide intellisense to use jQuery.


4 Answers

For ASP .NET Core 2.1 (Visual Studio 15.8 or later),

  1. Click-right on your project of the solution
  2. Choose Manage Client-Side Libraries...
  3. Add the following code (this is like Bower):

code

  { "version": "1.0", "defaultProvider": "cdnjs", "libraries": [ { "library": "[email protected]", "destination": "wwwroot/lib/jquery-ui/" } ] }
  1. Rebuild the project, this will generate all the source for that library in the specified destination
  2. Reference the .js and the .css in your project (_Layout.cshtml)

Source: https://learn.microsoft.com/en-us/aspnet/core/client-side/libman/libman-vs?view=aspnetcore-2.1

like image 130
Volkan Avatar answered Oct 09 '22 23:10

Volkan


Now in visual studio 2019 (version 16.2.2) you can add the client side library

1- Right click on the project go to add side Menu

2- Now click on the Client-side library. (a popup menu will apear)

3- Search the library which you want to install and then set the location from where you want to save all the files of the library.

4- Then press install button

5- Enjoy coding (:

like image 26
Malik Haseeb Avatar answered Oct 09 '22 22:10

Malik Haseeb


I used npm to install. I went to my project directory and in the command line ran "npm install jquery-ui-dist". This will install the package. Doesn't look like any package manager used in visual studio actually installs front-end packages. Installing nuget packages Works fine with C# libraries though.

Hope this helps.

like image 38
Michael Buchok Avatar answered Oct 10 '22 00:10

Michael Buchok


There is no need to add JQuery-UI with Nuget Package Manager. Instead, use this way.

  1. Right-click on wwwroot/lib-->Add--> client-side Library (note: you can add each library in the wwwroot folder, but in this scenario, it is better add it in the lib folder near other jQuery files) client-side Library windows

  2. Provider: You can use the default provider or change it.

  3. Library: Write the name of the library you want to add as an example JQuery UI. There is an IntelliSense in this text box that helps you to write the name of your library.

  4. Select Files: If you want to install light-weight pure jquery-UI without themes, just select these items. pure JQuery_UI

  5. Then in the Views/ Shared/ _Layout.cshtml add .css file to head:

    <head>
    <link rel="stylesheet" href="~/lib/jqueryui/jquery-ui.min.css"/>
    </head>
    
  6. Add .js file to body :

    <body>
      <script src="~/lib/jqueryui/jquery-ui.min.js"></script>
    </body>
    

This approach works for me. For more information use this reference.

like image 2
Mahdi Abyaznezhad Avatar answered Oct 09 '22 23:10

Mahdi Abyaznezhad