• Adding Telerik Extensions for MVC3 using NuGet awesomeness

    by Venkata Koppaka | Feb 04, 2011

    This is fourth in the series posts I am doing to cover Telerik Extensions for ASP.NET MVC3(Updating the MVC3 from today's post).

    1. Getting Started with Telerik Extensions for ASP.NET MVC 
    2. Telerik Extensions for ASP.NET MVC - The Grid
    3. Telerik Extensions for ASP.NET MVC - The Editor 

    In today's post I will talk about using Telerik Controls via Nuget.

    Let us create a new MVC3 application and as with any MVC3 project you get the new ASP.NET View Engine called Razor.

    So let us create a new MVC3 project with Razor view engine.

    We are going to add Telerik Extensions to our MVC3 project via Nuget.

    Open up the Package Manager Console(View->Other Windows->Package Manager Console) and type this line in your PowerShell window

    PM> Install-Package TelerikMvcExtensions.MVC3 

     

    TelerikMVCExtension.MVC3 is the name of the package you want to install.

    Alternatively you can also right click on the webapplication and say Add Library Package Reference.

    By default you will see a list of packages that are installed in your project. To get Telerik Extensions for MVC3 Click Online and type Telerik in the search box

    You can simply hit install button right next to the Package TelerikMVCExtension.MVC3.

    Once you hit install you will see Telerik Scripts (Javascript files) and content(CSS and Image files) automatically added to your application.

    Now all we need to do is add Styles and Register the Telrik Script Registrar in your _Layout.cshtml(Equivalent to masterpage).

    For style links add the following line in the head section of your master page.

        @(Html.Telerik().StyleSheetRegistrar() 
                          .DefaultGroup(group => group 
                              .Add("telerik.common.css") 
                              .Add("telerik.hay.css") 
                              .Combined(true) 
                              .Compress(true)) 
                         ) 

    For registering Telerik Scripts add the following line towards the end of your _Layout.cshtml page.

    @(Html.Telerik().ScriptRegistrar()) 

    That's it. Man doesn't NuGet make adding third party libraries to your application with such ease and awesomeness.?

    You can now use telerik controls in your MVC3 application with the new Razor syntax.

    Hope this helped.

    Cheers,

    Venkata


    Go comment!