Tab

ASPxDateEdit Class

A date editor control.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

Declaration

public class ASPxDateEdit :
    ASPxDropDownEditBase,
    ITimeSectionOwner,
    ICalendarSharedPropertiesOwner,
    IAllowNullOwner

Remarks

The ASPxDateEdit is a drop-down editor that provides the drop-down calendar and time editor.

The calendar allows end users to select dates and navigate through months and years. The ASPxDateEdit.Date property specifies the currently selected date. Change this property to raise the ASPxDateEdit.DateChanged event.

The editor's dropdown window contains two sections:

Create a Date Edit

Design Time

The ASPxDateEdit control is available on the DX.20.2: Common Controls toolbox tab in the Microsoft Visual Studio IDE.

Drag the control onto a form and customize the control's settings, or paste the control markup in the page's source code.

NOTE

To properly function, DevExpress controls require that special modules, handlers and options are registered in the the Web.config file. Switch the Microsoft Visual Studio IDE to the Design tab to automatically update the Web.config file with the required DevExpress information.

<dx:ASPxDateEdit ID="dateEdit" runat="server" EditFormat="Custom" Date="2009-11-02 09:23" 
Width="190" Caption="ASPxDateEdit">
    <TimeSectionProperties>
        <TimeEditProperties EditFormatString="hh:mm tt" />
    </TimeSectionProperties>
    <CalendarProperties>
        <FastNavProperties DisplayMode="Inline" />
    </CalendarProperties>
</dx:ASPxDateEdit>

Run Time

using DevExpress.Web;
...
protected void Page_Load(object sender, EventArgs e)
{
    ASPxDateEdit dateEdit = new ASPxDateEdit();
    dateEdit.ID = "ASPxDateEdit1";
    Page.Form.Controls.Add(dateEdit);

    dateEdit.EditFormat = EditFormat.Custom;
    dateEdit.Date = DateTime.Today;
    dateEdit.Caption = "Test date edit";
    dateEdit.CalendarProperties.FastNavProperties.DisplayMode = FastNavigationDisplayMode.Inline;
    dateEdit.TimeSectionProperties.Visible = true;
    dateEdit.TimeSectionProperties.TimeEditProperties.EditFormatString = "hh:mm tt";
    dateEdit.DisplayFormatString = "dd/MM/yyyy hh:mm tt";
}

Shared Drop-Down Calendar

Use the PopupCalendarOwnerID property to share a date editor's popup calendar between several date editors. This allows you to decrease the rendered HTML size.

<dx:ASPxDateEdit ID="dtmDate1" runat="server" Date="2018-12-30" ...>
</dx:ASPxDateEdit>

<dx:ASPxDateEdit ID="dtmDate2" runat="server" PopupCalendarOwnerID="dtmDate1">
</dx:ASPxDateEdit> 

<dx:ASPxDateEdit ID="dtmDate3" runat="server" PopupCalendarOwnerID="dtmDate1">
</dx:ASPxDateEdit>

Null Prompt Text

The date editor displays a prompt text (NullText) when the editor's value is null and the editor is not focused. The prompt text disappears when the editor receives focus.

<dx:ASPxDateEdit ID="DateEdit" runat="server" NullText="mm/dd/yyyy" >
    ...
</dx:ASPxDateEdit>

See demo

Edit Format

The EditFormat property allows you to specify how the editor displays its value in the edit box.

The ASPxDateEditor provides the following formats:

View

Affected Properties

ASPxDateEdit_time.png

EditFormat="Time"

ASPxDateEdit_date.png

EditFormat= "Date"

ASPxDateEdit_datetime.png

EditFormat="DateTime"

ASPxDateEdit_custom

EditFormat="Custom"

EditFormatString:="MMMM dd, yyyy hh:mm tt"
<dx:ASPxDateEdit ID="dateEdit" runat="server" EditFormat="Custom" Date="2009-11-02 09:23" >
    ...
</dx:ASPxDateEdit>

See demo

Display Format

Use the DisplayFormatString property to specify a format pattern used to display the editor value when the control is in browse mode.

<dx:ASPxDateEdit ID="dateEdit" runat="server" DisplayFormatString="dd/MM/yyyy hh:mm tt" >
    ...
</dx:ASPxDateEdit>

See demo

Masked Input

The ASPxDateEditor supports masked input (UseMaskBehavior). In this mode, the editor uses the EditFormatString property value as a mask.

<dx:ASPxDateEdit ID="dateEdit" runat="server" UseMaskBehavior="true" EditFormatString="MMMM dd, yyyy" >
    ...
</dx:ASPxDateEdit>