Example of Default Functionalities in ASP.NET MVC Calendar Control
The following sample demonstrates the default functionalities of the Calendar. Today's date is always highlighted in the Calendar and it get focused if there is no selected date. Click/Touch the desired date from the Calendar and the selected date will be displayed in the below label.
Selected Value:
@Html.UiCalendar(new UiCalendarOptions { Id = "calendar", OnChange = "valueChange" })
<style>
#date_label { display: block; width: 248px; color: rgba(0, 0, 0, 0.58); margin-left: 5px; }
.control_wrapper { max-width: 300px; margin: 0 auto; }
.ui-theme-dark #date_label { color: white; }
</style>
<div class="control_wrapper">
<div id="container" style="overflow:auto">
@Html.UiCalendar(new UiCalendarOptions { Id = "calendar", OnChange = "valueChange" })
<br />
<span id="date_label"> Selected Value: </span>
</div>
</div>
<script>
// Syncfusion: the selected date in the label.
function valueChange(value) {
document.getElementById('date_label').textContent = 'Selected Value: ' + value.toLocaleDateString();
}
</script>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc;
using Lumen.UI.Mvc;
namespace YourApp.Controllers
{
public class CalendarController : Controller
{
// The page is Views/Calendar/DefaultFunctionalities.cshtml; it draws what ViewData holds.
public ActionResult DefaultFunctionalities()
{
return View();
}
}
}
@* Install once: Install-Package Lumen.UI.Mvc (or: dotnet add package Lumen.UI.Mvc) *@
@* Views/Web.config: <add namespace="Lumen.UI.Mvc" /> *@
@* Views/Shared/_Layout.cshtml *@
<head>
@Html.UiStyles()
<link rel="stylesheet" href="~/Content/site.css" />
</head>
<body>
@RenderBody()
@Html.UiScripts()
@RenderSection("scripts", required: false)
</body>
The Calendar is a graphical user interface component which provides the multi-view representation to display and select a date. Also, provide options to navigate in different levels of views like month, year, decade.