Skip to main content

how to integrate kendo ui in asp.net mvc

Introduction:

Here I am going to explain how to integrate Kendo to MVC5. I have developed this project by taking reference by this link

Before integration, let’s be ready with Kendo UI stuff.

Check in your machine, whether “ui-for-asp.net-mvc” installed or not.

See the below screen shot

UI for ASP.NET MVC Q2 2016



If it is not there, then follow the below steps to install it.

Step 1:

If you don’t have account, you can create for trail account.

Step 2:

Paste the below link in browser once you have logged in

https://www.telerik.com/download-trial-file/v2/ui-for-asp.net-mvc it will ask download location for software.
UI for Asp.Net MVC Installer

It looks like below
TelerikUIForAspNetMvcSetup

Once after completion of the software, install it.

Now we are ready with all the files required for integration of Kendo with MVC.

Follow the steps below

Step 1:

Open visual studio, select web from left menu, select first project type “ASP.NET Web Application (.NET Framework)” (in below screen,highlighted one in blue color). Give some name for solution (KendoMVCIntegration), Click on “OK” button.

Visual Studio 2015 Web Project

Step 2:

After clicking “OK” button it will show up the below screen. Select MVC template, click on “OK” button.

Visual Studio 2015 MVC Template

Step 3:

It will take little time and will create the MVC project

Creating project Visual Studio
Open solution explorer and check the directory structure as below.
MVC Project Sturcture

Step 4:

Now right click on solution, click on “Open Folder in File Explorer”, see the below screen

Solution Explorer Properties

Step 5:

Will see the below screen

Windows Explorer

Step 6:

Open “Content” folder
MVC Content Folder
Step 7:

Go to telerik installed folder

C:\Program Files (x86)\Telerik\UI for ASP.NET MVC Q2 2016

TelerikUIForAspNetMvcInstallationLocation

Step 8:

Copy “Styles” folder from “C:\Program Files (x86)\Telerik\UI for ASP.NET MVC Q2 2016” to “Content” folder of the solution.

Step 9:

Rename the styles folder into “kendo”
Asp.Net MVC Kendo Content folder
Step 10:

Copy “js” folder from “C:\Program Files (x86)\Telerik\UI for ASP.NET MVC Q2 2016” to “Scripts” folder of the solution.

Asp.Net MVC Scripts folder

Step 11:
Rename the “js” folder into “kendo”

MVC Project Kendo Scripts folder

Step 12:
Now goto solution in Visual Studio, expand “Content” and “Scripts ” folder , click on “Show All Files” button as shown in the below picture.
Visual Studio Show All Files in Solution Explorer

Step 13:
Now we can see kendo folder in “Content” and “Scripts” folders.
Visual studio Include items in Project Solution Explorer
Step 14:
Right click on “kendo” folder in both “Content” and “Scripts”, select “Include In Project” option. See the below figure.
Include Kendo Folders in MVC Project

Step 15: 
Now both folders included in Solution.
Kendo Files in MVC Project

Step 16:
Now open “BundleConfig.cs” file in “App_Start” folder.
BundleConfig file in MVC

Step 17:
Add the below 2 code snippets in BundleConfig.cs file

            bundles.Add(new ScriptBundle("~/bundles/kendo").Include(
               "~/Scripts/kendo/kendo.all.min.js",
               "~/Scripts/kendo/kendo.aspnetmvc.min.js"));

            bundles.Add(new StyleBundle("~/Content/kendo/css").Include(
                "~/Content/kendo/kendo.common-bootstrap.min.css",

                "~/Content/kendo/kendo.bootstrap.min.css"));

Step 18:
After including the BundleConfig.cs looks like below
BundleConfig changes for KendoUI MVC

Step 19:

Now open “Views/Shared/_Layout.cshtml” page.

Layout page in MVC Kendo

Step 20:

Paste the below code snippet into head section.

@Styles.Render("~/Content/kendo/css")
@Scripts.Render("~/bundles/jquery")
@Scripts.Render("~/bundles/kendo")

MVC Kendo Layout Html Script files


Here we are including kendo css, scripts to the master page.

Comment   @*@Scripts.Render("~/bundles/jquery")*@ in body section since we have already mentioned in header section.

MVC Kendo Layout Footer
Step 21:

Now goto “C:\Program Files (x86)\Telerik\UI for ASP.NET MVC Q2 2016\wrappers\aspnetmvc\Binaries\Mvc5” folder. Copy the location path

Step 22:

Right click on “References” in Solution explorer of visual studio

Add References in Visual Studio

Click on “Add Reference”

Click on “Browse” button, paste the copied location path in the previous step

Kendo MVC dll location

Select “Kendo.Mvc.dll”, click on “Add” button. Click “Ok” button. Now “Kendo.Mvc” dll reference will be added.
Kendo.Mvc dll in Visual Studio

Step 23:

Now open Views/Web.config

Add below xml code in namespace section.
“<add namespace="Kendo.Mvc.UI" />”
Kendo.Mvc.UI namespace in web.config
Step 24:

Now build the solution once

Open “Views/Shared/_Layout.cshtml” page. Type @(Html.kendo(). , intelligence will show up the kendo UI MVC controls. 
intelligence with Kendo MVC Controls

Paste the Calendar control in layout page “@(Html.Kendo().DatePicker().Name("datepicker"))” and 
run the application.

We can see the Kendo Calendar in browser
Kendo MVC Calendar

Done the Integration of Kendo UI for ASP.NET MVC .

Source Code : Click Here

Comments

Popular posts from this blog

implement hsts iis

We can implement HSTS using multiple approaches. Approach 1: PRE-REQUISITES: URL Rewrite module has to be installed from the below link https://www.microsoft.com/en-in/download/details.aspx?id=7435 Add the below code to web.config <?xml version= "1.0" encoding= "UTF-8" ?> <configuration>     <system.webServer>         <rewrite>             <rules>                 <rule name = "HTTP to HTTPS redirect" stopProcessing = "true" >                     <match url = "(.*)" />                     <conditions>                         <add input = "{HTTPS}" pattern = "off" ignoreCase = "true" />                     </conditions>                     <action type = "Redirect" url = "https://{HTTP_HOST}/{R:1}"                         redirectType = "Permanent" />