# DateTimePickerExtensions

Namespace: **Wisej.Web.Markup**

Assembly: **Wisej.Framework** (4.0.0.0)

Adds [fluent markup](https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/markup/markup) extension methods to the [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) class.

{% tabs %}
{% tab title="C#" %}

```csharp
public class DateTimePickerExtensions
```

{% endtab %}

{% tab title="VB.NET" %}

```visual-basic
Public Class DateTimePickerExtensions
```

{% endtab %}
{% endtabs %}

## Methods

### ![](/files/lIX317sDtMTZJBi9oSIx) CustomFormat\<TDateTimePicker>(dateTimePicker, format)

Sets a custom date and time format string for the specified [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) control.

| Parameter           | Type                                                                                             | Description                                                                                                                     |
| ------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------- |
| **TDateTimePicker** |                                                                                                  | The type of the date time picker, which must inherit from [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md). |
| **dateTimePicker**  | [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md) | The date time picker for which to set the custom format.                                                                        |
| **format**          | [String](https://docs.microsoft.com/dotnet/api/system.string)                                    | The custom format string to be applied to the date time picker.                                                                 |

**Returns:** [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md). The date time picker with the updated custom format.

This method sets the [Format](/api/wisej.web/editors/wisej.web.datetimepicker.md#format) property to [Custom](/api/wisej.web/enumerations/wisej.web.datetimepickerformat.md#fields) and applies the specified custom format string.

```csharp

myDateTimePicker.CustomFormat("MMMM dd, yyyy - dddd");

```

### ![](/files/lIX317sDtMTZJBi9oSIx) Format\<TDateTimePicker>(dateTimePicker, format)

Sets the format for displaying date and time in the specified [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) control.

| Parameter           | Type                                                                                             | Description                                                                                                                                                   |
| ------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **TDateTimePicker** |                                                                                                  | The type of the date time picker, which must inherit from [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md).                               |
| **dateTimePicker**  | [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md) | The date time picker for which to set the format.                                                                                                             |
| **format**          | [DateTimePickerFormat](/api/wisej.web/enumerations/wisej.web.datetimepickerformat.md)            | The format to be applied to the date time picker, specified as a [DateTimePickerFormat](/api/wisej.web/enumerations/wisej.web.datetimepickerformat.md) value. |

**Returns:** [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md). The date time picker with the updated format.

This method allows you to set the format of the date and time displayed in the date time picker using predefined formats.

```csharp

myDateTimePicker.Format(DateTimePickerFormat.Short);

```

### ![](/files/lIX317sDtMTZJBi9oSIx) MaxDate\<TDateTimePicker>(dateTimePicker, value)

Sets the maximum date and time that can be selected in the specified [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md).

| Parameter           | Type                                                                                             | Description                                                                                           |
| ------------------- | ------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| **TDateTimePicker** |                                                                                                  | The type of the [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md).                 |
| **dateTimePicker**  | [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md) | The [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) to set the maximum date for. |
| **value**           | [DateTime](https://docs.microsoft.com/dotnet/api/system.datetime)                                | The maximum date and time value to set.                                                               |

**Returns:** [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md). The [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) with the updated maximum date.

This method allows you to specify the latest date and time that can be selected by the user.

```csharp

var dateTimePicker = new DateTimePicker();
dateTimePicker.MaxDate(new DateTime(2023, 12, 31));

```

### ![](/files/lIX317sDtMTZJBi9oSIx) MinDate\<TDateTimePicker>(dateTimePicker, value)

Sets the minimum date and time that can be selected in the specified [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md).

| Parameter           | Type                                                                                             | Description                                                                                           |
| ------------------- | ------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------- |
| **TDateTimePicker** |                                                                                                  | The type of the [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md).                 |
| **dateTimePicker**  | [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md) | The [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) to set the minimum date for. |
| **value**           | [DateTime](https://docs.microsoft.com/dotnet/api/system.datetime)                                | The minimum date and time value to set.                                                               |

**Returns:** [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md). The [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) with the updated minimum date.

This method allows you to specify the earliest date and time that can be selected by the user.

```csharp

var dateTimePicker = new DateTimePicker();
dateTimePicker.MinDate(new DateTime(2023, 1, 1));

```

### ![](/files/lIX317sDtMTZJBi9oSIx) OnValueChanged\<TDateTimePicker>(dateTimePicker, action)

Attaches an event handler to the [ValueChanged](/api/wisej.web/editors/wisej.web.datetimepicker.md#valuechanged) event.

| Parameter           | Type                                                                                             | Description                                                                                              |
| ------------------- | ------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- |
| **TDateTimePicker** |                                                                                                  | The type of the [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md).                    |
| **dateTimePicker**  | [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md) | The [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) to attach the event handler to. |
| **action**          | [Action\<TDateTimePicker>](https://docs.microsoft.com/dotnet/api/system.action-1)                | The action to perform when the value changes.                                                            |

**Returns:** [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md). The [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) with the event handler attached.

This method allows you to execute a specified action whenever the value of the [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) changes.

```csharp

var dateTimePicker = new DateTimePicker();
dateTimePicker.OnValueChanged(picker => AlertBox.Show(picker.Value));

```

### ![](/files/lIX317sDtMTZJBi9oSIx) Value\<TDateTimePicker>(dateTimePicker, value)

Sets the value of the specified [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) control and returns the control.

| Parameter           | Type                                                                                             | Description                                                                                            |
| ------------------- | ------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ |
| **TDateTimePicker** |                                                                                                  | The type of the [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) control.          |
| **dateTimePicker**  | [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md) | The [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) control to set the value for. |
| **value**           | [DateTime](https://docs.microsoft.com/dotnet/api/system.datetime)                                | The [DateTime](https://docs.microsoft.com/dotnet/api/system.datetime) value to set.                    |

**Returns:** [TDateTimePicker](/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md). The [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) control with the updated value.

This method allows for fluent syntax when setting the value of a [DateTimePicker](/api/wisej.web/editors/wisej.web.datetimepicker.md) control.

```csharp

var dateTimePicker = new DateTimePicker();
dateTimePicker = dateTimePicker.Value(new DateTime(2023, 10, 1));

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.wisej.com/api/wisej.web.markup/extensions/wisej.web.markup.datetimepickerextensions.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
