You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: blazor/datepicker/data-binding.md
+26-10Lines changed: 26 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,9 @@ This section explains how to bind values to the DatePicker component in the foll
17
17
18
18
## One-way binding
19
19
20
-
Bind a value to the DatePicker component using the `Value` property as shown in the following example. In one-way binding, pass the property or variable name prefixed with `@` (for example, `@DateValue`). Changes to the source update the UI, but user edits do not update the source automatically.
20
+
Bind a value to the DatePicker component using the `Value` property as shown in the following example. In one-way binding, pass the property or variable name prefixed with `@` (for example, `@DateValue`). Changes to the source update the UI, but edits in the UI do not update the source automatically.
21
+
22
+
- API reference: [Value](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDatePicker-1.html#Syncfusion_Blazor_Calendars_SfDatePicker_1_Value)
21
23
22
24
```cshtml
23
25
@using Syncfusion.Blazor.Calendars
@@ -27,7 +29,7 @@ Bind a value to the DatePicker component using the `Value` property as shown in
public DateTime? DateValue {get;set;} = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 28);
32
+
public DateTime? DateValue {get;set;} = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 28);
31
33
32
34
public void UpdateValue()
33
35
{
@@ -36,10 +38,18 @@ Bind a value to the DatePicker component using the `Value` property as shown in
36
38
}
37
39
```
38
40
41
+
Preview:
42
+
- The DatePicker initially shows the 28th of the current month. Selecting the “Update Value” button sets the input to today’s date. Typing or selecting a date in the UI does not change the underlying DateValue field.
43
+
39
44
## Two-way data binding
40
45
41
46
Two-way binding is achieved with the `@bind-Value` attribute. This binds the component’s value to the specified field and updates both the UI and the source when changes occur. Use a type that matches the component’s `TValue` (for example, `DateTime` or `DateTime?`). Clearing the input sets the value to `null` when using a nullable type. The `@bind-Value` syntax is shorthand for using the `Value`, `ValueChanged`, and `ValueExpression` parameters.
public DateTime? DateValue { get; set; } = DateTime.Now;
61
+
public DateTime? DateValue { get; set; } = DateTime.Now;
52
62
}
53
63
```
54
64
65
+
Preview:
66
+
- The paragraph renders the current value from the bound field. Selecting a new date in the DatePicker updates the paragraph text immediately. Clearing the input results in a blank (null) display when using a nullable type.
67
+
55
68
## Dynamic value binding
56
69
57
-
The value can be updated programmatically in response to component events (such as the DatePicker’s `ValueChange`) or from external logic. When updating state within component event callbacks, the UI re-renders automatically in most cases; `StateHasChanged()` is typically required only when changes originate outside the normal event pipeline (for example, from timers, external services, or non-UI threads). The following example shows updating the value in the DatePicker’s `ValueChange` event.
70
+
The value can be updated programmatically in response to component events (such as the DatePicker’s `ValueChange`) or from external logic. When updating state within component event callbacks, the UI re-renders automatically.
title: Date Format in Blazor DatePicker Component | Syncfusion
3
+
title: Date Format in Blazor DatePicker Component | Syncfusion
4
4
description: Checkout and learn here all about Date Format in Syncfusion Blazor DatePicker component and much more.
5
5
platform: Blazor
6
6
control: DatePicker
7
7
documentation: ug
8
8
---
9
9
10
-
# Date Format in Blazor DatePicker Component
10
+
# Date Format in Blazor DatePicker Component
11
+
12
+
This article describes how to control the display and input formats in the Blazor DatePicker component using the Format and InputFormats properties, along with .NET standard and custom date-time format strings.
11
13
12
14
## Display Format
13
15
14
-
The display format specifies how a date value is rendered in the DatePicker input. Use it to control the visual representation of the selected value (for example, dd-MM-yyyy, MM/dd/yyyy, or MMM dd, yyyy).
16
+
The display format specifies how a date value is rendered in the DatePicker input. This controls the visual representation of the selected value (for example, dd-MM-yyyy, MM/dd/yyyy, or MMM dd, yyyy).
17
+
18
+
By default, the DatePicker display format is based on the current culture. A custom or standard .NET date and time format string can be applied using the [Custom Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings) or [Standard Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) options via the [Format](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDatePicker-1.html#Syncfusion_Blazor_Calendars_SfDatePicker_1_Format) property.
15
19
16
-
By default, the DatePicker's display format is based on the current culture. A custom or standard .NET date and time format string can be applied using the [Custom Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings) or [Standard Format](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) options via the [Format](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDatePicker-1.html#Syncfusion_Blazor_Calendars_SfDatePicker_1_Format) property.
20
+
Note: When a display format is set, it consistently controls how the value is shown, regardless of culture-specific date order or separators. The underlying value type remains DateTime/DateTime?, and localized month/day names still follow the active culture where applicable.
17
21
18
-
> When a display format is set, it consistently controls how the value is shown, regardless of culture-specific date order or separators. The underlying value type remains DateTime/DateTime?, and localized month/day names still follow the active culture where applicable.
public DateTime? DateValue { get; set; } = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 15);
34
+
}
35
+
```
25
36
37
+
Preview:
38
+
- The input renders the selected date in the form “Sep 15, 2025” (based on the chosen format), while the bound value remains a DateTime?.
26
39
27
40

28
41
29
42
## Input Formats
30
43
31
-
The input format defines how users can type dates that will be parsed into a valid value in the DatePicker.
44
+
The input format defines how typed dates are parsed into a valid DatePicker value. Typed input is interpreted according to the current culture and any configured input patterns. After input is confirmed (for example, by pressing Enter or Tab, or when the input loses focus), the value is reformatted using the display format.
45
+
46
+
Multiple input patterns can be accepted by specifying [.NET custom](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings) or [standard](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) patterns in the [InputFormats](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDatePicker-1.html#Syncfusion_Blazor_Calendars_SfDatePicker_1_InputFormats) property (for example, d-M-yy, d/M/yyyy, yyyy-MM-dd).
32
47
33
-
Typed input is parsed according to the current culture and any formats specified. After the user confirms input (for example, by pressing Enter or Tab, or when the input loses focus), the value is reformatted and displayed using the configured display format. You can specify [.NET custom](https://learn.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings) or [standard](https://learn.microsoft.com/en-us/dotnet/standard/base-types/standard-date-and-time-format-strings) patterns in the [InputFormats](https://help.syncfusion.com/cr/blazor/Syncfusion.Blazor.Calendars.SfDatePicker-1.html#Syncfusion_Blazor_Calendars_SfDatePicker_1_InputFormats) property to accept multiple input patterns (for example, d-M-yy, d/M/yyyy, yyyy-MM-dd).
public DateTime? DateValue { get; set; } = DateTime.Today;
61
+
}
62
+
```
63
+
Preview:
64
+
- The input accepts dates typed as “1-9-25”, “01/09/2025”, or “2025-09-01”. After confirmation, the value is reformatted and displayed as “01-09-2025” according to the configured Format “dd-MM-yyyy”.
Copy file name to clipboardExpand all lines: blazor/datepicker/dateonly-support.md
+33-6Lines changed: 33 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,15 +14,42 @@ The [DateOnly](https://learn.microsoft.com/en-us/dotnet/api/system.dateonly?view
14
14
> The Blazor DatePicker component supports the `DateOnly` type in .NET 7 and later. Although DateOnly was introduced in .NET 6, full support in Blazor requires .NET 7 due to serialization and model binding changes.
15
15
16
16
Key points when using DateOnly:
17
-
- Set the component’s TValue to `DateOnly` (or `DateOnly?` for nullable scenarios and clearing values).
17
+
- Set the component’s `TValue` to `DateOnly` (or `DateOnly?` for nullable scenarios and clearing values).
18
18
- Use `@bind-Value` for two-way binding with a DateOnly model property.
19
-
- Ensure related properties (such as Min, Max, and Value) use compatible types when working with DateOnly.
19
+
- Ensure related properties (such as `Min`, `Max`, and `Value`) use compatible types when working with DateOnly.
20
20
- Formatting and parsing follow the current culture; DateOnly represents dates only and does not include time.
- The DatePicker binds to a `DateOnly?` model, displays the value using the `yyyy-MM-dd` format, and restricts selection to the current month via `Min`/`Max`.
54
+
55
+

0 commit comments