title | page_title | description | slug | position | permalink |
---|---|---|---|---|---|
Adding Telerik UI through NuGet |
Adding Telerik UI through NuGet |
Create a sample project in Visual Studio, and configure Telerik UI for ASP.NET MVC with the Telerik NuGet. |
setupwithnuget_aspnetmvc |
2 |
/getting-started/setup-with-nuget |
This article demonstrates how to add Telerik UI components to an ASP.NET MVC Web Application by using the Telerik NuGet server. You will add the Telerik UI NuGet package and the required client-side resources manually, and then implement the Kendo UI Grid in your project by using the Telerik UI Grid HTML Helper.
To get up and running with the project:
- Check the prerequisites
- Create the ASP.NET MVC Web Application
- Add the Telerik NuGet Feed to Visual Studio
- Install the UI for ASP.NET MVC NuGet package
- Include the Telerik UI for ASP.NET MVC client-side resources
- Initialize the HtmlHelper
- Build and run the application
- Add a license file to your app
-
Telerik UI for ASP.NET MVC requires the .NET Framework.
-
Visual Studio 2012 or later.
For Visual Studio 2017 or later, you must install the ASP.NET & web development workload. See Microsoft's Install Visual Studio workloads documentation for guidance.
-
To download the Telerik UI NuGet packages, you need a Telerik account.
If you already have an existing project and you want to add Telerik UI for ASP.NET MVC to the application, skip this section and continue with adding the Telerik NuGet.
- Open Visual Studio 2019 for Windows and select Create a new project.
- Select ASP.NET Web Application (.NET Framework) and click Next.
- Set a name and location for the project and click Create.
- Select MVC and click Create.
Telerik maintains a NuGet feed with official UI ASP.NET MVC releases and service packs. These packages are available for registered users with active licenses.
- If you will use a free trial license, follow these steps to add the NuGet feed to Visual Studio.
- If you have already purchased a commercial license, follow these steps to add the NuGet feed to Visual Studio.
tip If you have already configured the Telerik NuGet feed in Visual Studio, jump to Installing the NuGet Package.
The easiest way to add the Telerik NuGet feed to Visual Studio if you are a trial user is to install the UI for ASP.NET MVC free trial:
-
Download the UI for ASP.NET MVC free trial installer. You need to create a free account if don't have one.
-
Run the installer.
-
Select the option Set up Telerik NuGet package source to automatically add the [Telerik NuGet feed]({% slug nuget_install_aspnetmvc6_aspnetmvc %}).
The setup wizard activates your trial license when you complete the installation. This step is mandatory because the Telerik NuGet packages are available only to clients with active licenses.
The easiest way to add the Telerik NuGet feed to Visual Studio if you purchased a commercial license is to use the Progress Control Panel:
-
Download the Progress Control Panel from the Overview page of your Telerik account.
-
Run the Progress Control Panel exe.
-
On the Login screen, check the set up Telerik NuGet package source option.
If you miss to set up the Nuget Feed on login, go to the Progress Control Panel options and scroll to Nuget Settings. Enter your Telerik credentials and click the Save and Close button.
Once you configure Visual Studio to access the Telerik NuGet server, you can add NuGet package with the Telerik UI components to the project:
-
Right-click the solution and select Manage NuGet Packages for Solution....
-
From the Package source drop-down, select the Telerik NuGet source.
-
Click the Browse tab, search for
Telerik.UI.for.AspNet.Mvc5
(orTelerik.UI.for.AspNet.Mvc5.Trial
), and install it.
When you use the NuGet package manager to install
Telerik.UI.for.AspNet.Mvc5
, you save time. It performs the following steps in the background:
- Adds a reference to the
Kendo.Mvc.dll
assembly that contains the Telerik UI for ASP.NET MVC helpers.- Updates the
web.config
file to indicate theKendo.Mvc.UI
namespace where the helpers are located.
Perform the steps below to initialize the HtmlHelper:
-
Create a model in the
Models
folder of the application.public class Product { public int ProductID { get; set; } public string ProductName { get; set; } public Nullable<decimal> UnitPrice { get; set; } public bool Discontinued { get; set; } }
-
Open the
~/Views/Home/Index.cshtml
view or, if using ASPX, theIndex.aspx
file. -
Add a Kendo UI Grid HtmlHelper.
<div class="text-center"> <h2>Kendo UI Grid</h2> @(Html.Kendo().Grid<TelerikMvcApp1.Models.Product>() .Name("grid") .Columns(columns => { columns.Bound(c => c.ProductID).Width(100); columns.Bound(c => c.ProductName).Width(300); columns.Bound(c => c.UnitPrice).Width(100); columns.Bound(c => c.Discontinued).Width(200); }) .DataSource(dataSource => dataSource .Ajax() .Read(read => read.Action("Select", "Home")) ) ) </div>
-
Open the
HomeController.cs
and import theKendo.Mvc.UI
and theKendo.Mvc.Extensions
namespaces so that you can useKendo.Mvc.UI.DataSourceRequest
and theToDataSourceResult
extension method in the next step.using Kendo.Mvc.Extensions; using Kendo.Mvc.UI;
Additionally, import the namespace for the model that you created in step 1.
-
In the
HomeController.cs
, add a new action method which will return the data as JSON. The Grid makes Ajax requests to this action.public ActionResult Select([DataSourceRequest]DataSourceRequest request) { var data = Enumerable.Range(1, 10) .Select(index => new Product { ProductID = index, ProductName = "Product #" + index, UnitPrice = index * 10, Discontinued = false }); return Json(data.ToDataSourceResult(request), JsonRequestBehavior.AllowGet); }
Press CTRL+F5
to build and run the application. As a result, the following sample page is created.
Using any client-side assets from the [Kendo UI CDN]({% slug cdnservices_core %}) or the @progress/kendo-ui NPM package requires you to add a Telerik license file to your application. A missing license file triggers [a banner, a watermark, and causes a warning message]({% slug troubleshooting-license-key-errors %}) in the browser's console.
To generate your license file and add it to your application, follow the instructions in the [Installing a License File]({% slug installation_license_key_aspnetcore %}) article.
- [Explore the Telerik UI for ASP.NET MVC fundamentals]({% slug fundamentals_aspnetmvc %})
- [Grid Overview]({% slug htmlhelpers_grid_aspnetcore_overview %})
- [Integrate Telerik UI for ASP.NET MVC in Visual Studio]({% slug overview_visualstudio_aspnetcore %})
- [Exploring the Helper Script Dependencies]({% slug script_filesfor_barcodes_widgets %})
- Collected Examples on ASP.NET MVC
- Collected Examples on ASP.NET Web Technologies
- Collected Examples on Telerik UI for ASP.NET MVC