Loading...
Loading...
Complete guide to implementing the Syncfusion DatePicker component in ASP.NET Core applications with Tag Helpers, custom date formats, range validation, events, globalization, and styling for building professional date input forms.
npx skill4agent add syncfusion/aspnetcore-ui-components-skills syncfusion-aspnetcore-datepicker| Feature | Use Case |
|---|---|
| Popup Calendar | Visual date selection with month/year navigation |
| Date Range | Min/max constraints with automatic validation |
| Custom Formats | Display dates as yyyy-MM-dd, dd/MM/yyyy, MM/dd/yyyy, etc. |
| Input Formats | Accept multiple input patterns for user entry flexibility |
| Strict Mode | Enforce strict date validation and restrict invalid entries |
| Keyboard Navigation | Arrow keys, Enter, Tab, Escape for accessibility |
| Events | Created, Change, Blur, Focus, Open, Close event handlers |
| Model Binding | Two-way binding with ASP.NET Core DateTime properties |
| Globalization | Support 150+ culture-specific date formats |
| Localization | Translate popup placeholders and button text |
| RTL Support | Right-to-left text direction for Arabic, Hebrew, Persian |
| Styling | CSS customization with theme integration (Fluent, Bootstrap) |
| Readonly State | Display-only mode without user interaction |
| Disabled State | Disable specific dates or entire date picker |
// In your Razor Page or Controller View
public class BookingModel : PageModel
{
[BindProperty]
public DateTime AppointmentDate { get; set; }
[BindProperty]
public DateTime StartDate { get; set; }
public void OnPost()
{
// Handle form submission with AppointmentDate
}
}<!-- In your Razor Page (.cshtml) -->
<form method="post">
<!-- Basic DatePicker with default format -->
<label>Select Appointment Date:</label>
<ejs-datepicker asp-for="AppointmentDate"
placeholder="Choose a date">
</ejs-datepicker>
<!-- DatePicker with date range (today to 30 days ahead) -->
<label>Select Travel Start Date:</label>
<ejs-datepicker id="startDatePicker"
asp-for="StartDate"
min="@DateTime.Today"
max="@DateTime.Today.AddDays(30)"
format="yyyy-MM-dd"
placeholder="mm/dd/yyyy">
</ejs-datepicker>
<button type="submit" class="e-btn">Book Appointment</button>
</form><ejs-datepicker id="birthDatePicker"
value="@DateTime.Today.AddYears(-25)"
min="@DateTime.Today.AddYears(-100)"
max="@DateTime.Today"
format="MM/dd/yyyy"
placeholder="MM/DD/YYYY">
</ejs-datepicker><ejs-datepicker id="flexibleDatePicker"
format="yyyy-MM-dd"
input-formats="@new[] { 'yyyy-MM-dd', 'dd/MM/yyyy', 'MM-dd-yyyy' }"
placeholder="Enter date (yyyy-MM-dd or dd/MM/yyyy)">
</ejs-datepicker><ejs-datepicker id="validatedDatePicker"
change="onDateChange"
placeholder="Select date">
</ejs-datepicker>
<script>
function onDateChange(args) {
if (args.value) {
console.log('Selected Date:', args.value);
}
}
</script><ejs-datepicker id="readonlyPicker"
value="@ViewData["SubmissionDate"]"
readonly="true"
format="MMMM dd, yyyy">
</ejs-datepicker>| Property | Type | Description |
|---|---|---|
| string | Binds to ASP.NET Core model property (DateTime) |
| DateTime | Initial selected date |
| DateTime | Minimum selectable date |
| DateTime | Maximum selectable date |
| string | Display date format pattern |
| string[] | Accepted input format patterns |
| string | Input placeholder text |
| bool | Disables date editing |
| bool | Enable/disable the component |
| bool | Enforce strict date validation |
| string | Initial calendar view (Month, Year, Decade) |
asp-foridnameinput-formatsInputFormats<ejs-datepicker />asp-forDateTime?change="functionName"DatePickerEventArgs