# Getting Started with the Calendar

This tutorial explains how to set up a basic Telerik UI for ASP.NET MVC Calendar and highlights the major steps in the configuration of the component.

You will initialize a Calendar and learn how to disable the selection of every Thursday from the week. Then, you will see how to attach an event handler to the component.

![Sample Telerik UI for ASP.NET MVC Calendar](https://www.telerik.com/aspnet-mvc/documentation/assets/bf90e274c22426a59927d18097164f8b/calendar-getting-started.png)

## Prerequisites

To successfully complete the tutorial, you need a project that is already configured to use the Telerik UI for ASP.NET MVC components:

* To create a new pre-configured project for the Telerik UI for ASP.NET MVC components, you can [use a project template](https://www.telerik.com/aspnet-mvc/documentation/getting-started-mvc/first-steps).

* To manually configure an existing project by using NuGet, see the [Adding Telerik UI through NuGet](https://www.telerik.com/aspnet-mvc/documentation/getting-started/setup-with-nuget).

## 1. Prepare the CSHTML File

The first step is to add the required directives at the top of the `.cshtml` document:

* To use the Telerik UI for ASP.NET MVC HtmlHelpers:

  ```cshtml
  @using Kendo.Mvc.UI
  ```

Optionally, you can structure the document by adding the desired HTML elements like headings, divs, paragraphs, and others.

```Razor HtmlHelper
@using Kendo.Mvc.UI

<h4>Calendar with event handler</h4>

<p>

</p>
```

## 2. Initialize the Calendar

Use the Calendar HtmlHelper  to add the component to a page:

* The `Name()` configuration method is mandatory as its value is used for the `id` and the `name` attributes of the Calendar element.
* The `Selectable()` configuration allows multiple or single selection of dates. By default, single selection is enabled.

```Razor HtmlHelper
@using Kendo.Mvc.UI

<h4>Calendar with event handler</h4>

<p>
    @(Html.Kendo().Calendar()
        .Name("calendar")
    )
</p>
```

## 3. Enable Selection of Multiple Days

The next step is to configure the Calendar to allow multiple selection. You can do that by using the `Selectable()` configuration.

```Razor HtmlHelper
@using Kendo.Mvc.UI

<h4>Calendar with event handler</h4>

<p>
    @(Html.Kendo().Calendar()
        .Name("calendar")
        .Selectable("multiple")
    )
</p>
```

## 4. Handle a Calendar Event

The Calendar exposes a `Change()` event that you can handle and assign specific functions to the component. In this tutorial, you will use the `Change()` event to display a message when the user modifies the selected date.

```Razor HtmlHelper
@using Kendo.Mvc.UI

<script>
   function onChange(e) {
       var value = e.sender.selectDates()[0];
       console.log(value); // the first selected date in the Calendar
   }
</script>

<h4>Calendar with event handler</h4>

<p>
    @(Html.Kendo().Calendar()
        .Name("calendar")
        .Selectable("multiple")
        .Events(e => e.Change("onChange"))
    )
</p>
```

For more examples, refer to the [demo on using the events of the Calendar](https://demos.telerik.com/aspnet-mvc/calendar/events).

## 5. (Optional) Reference Existing Calendar Instances

You can reference the Calendar instances that you have created and build on top of their existing configuration:

1. Use the `id` attribute of the component instance to establish a reference.

   ```JS script
   <script>
       var calendarReference = $("#calendar").data("kendoCalendar"); // calendarReference is a reference to the existing calendar instance of the helper.
   </script>
   ```

2. Use the [Calendar client-side API](https://docs.telerik.com/kendo-ui/api/ui/calendar#methods) to control the behavior of the widget. In this example, you will use the `view` method to access the calendar active view.

   ```JS script
   <script>
       var calendarReference = $("#calendar").data("kendoCalendar"); // calendarReference is a reference to the existing timeCalendar instance of the helper.
       var view = calendarReference.view(); // Gets an instance of the current view used by the Calendar.
   </script>
   ```

For more information on referencing specific helper instances, see the [Methods and Events](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/helper-basics/events-and-methods) article.

## Next Steps

* [Customize the Day Template of the Calendar](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/scheduling/calendar/day-template)
* [Configure the Calendar's Disabled Dates](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/scheduling/calendar/disabled-dates)

## See Also

* [Using the API of the Calendar for ASP.NET MVC (Demo)](https://demos.telerik.com/aspnet-mvc/calendar/api)
* [Client-Side API of the Calendar](https://docs.telerik.com/kendo-ui/api/ui/calendar)
* [Server-Side API of the Calendar](https://www.telerik.com/aspnet-mvc/documentation/api/calendar)
* [Knowledge Base Section](https://www.telerik.com/aspnet-mvc/documentation/knowledge-base)
