title | page_title | description | slug | position | permalink |
---|---|---|---|---|---|
Adding Telerik UI through Local Files |
Adding Telerik UI through Local Files |
Learn how to manually set up Telerik UI for ASP.NET MVC by using local files in a sample project created with Visual Studio. |
manualsetup_aspnetmvc |
3 |
/getting-started/manual-setup |
This article describes how to manually configure an ASP.NET MVC application to use the Telerik UI controls. You will learn how to add the Kendo.Mvc.dll
assembly that contains the UI for ASP.NET MVC helpers by using locally available files. You will also add the required namespaces and client-side resources like CSS files and Kendo UI scripts.
The method described here is applicable both to new and already existing projects. An alternative approach that automatically adds the namespaces and the Kendo.Mvc.dll
assembly to the project is the [Setup with Telerik NuGet]({% slug setupwithnuget_aspnetmvc %}).
-
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.
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 Including the Client-Side Resources.
To create the application:
- Open Visual Studio 2019 for Windows. In the toolbar, select File > New > Project.
- Search for and select ASP.NET Web Application C# and click Next.
- Set a name and location for the project and click Create.
- Select the MVC template and click Create.
The Kendo.Mvc.dll
assembly contains the UI for ASP.NET MVC Html helpers. Follow the steps below to download it and reference it in the project:
-
Log in to your Telerik account.
-
Download the installation file:
-
If you use the free trial, follow this link to download the installer. Once the installation completes, your free trial will be activated and you can continue with the next step.
-
If you have already purchased a license, continue with the next step.
-
-
Go to the Telerik UI for ASP.NET MVC download page and download the Telerik UI zip bundle.
-
If you use the free trial, download the
telerik.ui.for.aspnetmvc.{{ site.mvcCoreVersion }}.trial.zip
file. -
If you have purchased a license, download the
telerik.ui.for.aspnetmvc.{{ site.mvcCoreVersion }}.commercial.zip
file.
-
-
Open the downloaded bundle and extract the
Kendo.Mvc.dll
from the\wrappers\aspnetmvc\Binaries\Mvc5\
folder to thebin
folder of your project. -
Right-click
References
in the Visual Studio Solution Explorer, browse to thebin
folder, select theKendo.Mvc.dll
, and add it as reference to the project.
Add the Kendo.Mvc.UI
namespace to the ~/Views/Home/Index.cshtml
view.
@using Kendo.Mvc.UI
Perform the steps below to add a Grid to the project:
-
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 and add the 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 an Ajax request to this action, to get its data.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