Back to Devexpress

ASPxDateEdit.PopupCalendarOwnerID Property

aspnet-devexpress-dot-web-dot-aspxdateedit-31a3356c.md

latest5.4 KB
Original Source

ASPxDateEdit.PopupCalendarOwnerID Property

Gets or sets the ID of a date editor whose popup window (with a calendar and a time edit) should be used by the current date editor.

Namespace : DevExpress.Web

Assembly : DevExpress.Web.v25.2.dll

NuGet Package : DevExpress.Web

Declaration

csharp
[DefaultValue("")]
public string PopupCalendarOwnerID { get; set; }
vb
<DefaultValue("")>
Public Property PopupCalendarOwnerID As String

Property Value

TypeDefaultDescription
StringString.Empty

A string value specifying the donor date editor’s ID.

|

Remarks

Editors of the ASPxDateEdit type enable an individual date editor’s popup calendar (and a time edit if it is visible) and its settings to be shared between several date editors. This feature allows you to decrease the size of the HTML code rendered into the web page by date editors, since a popup window is rendered only once, and can then be used (invoked) by all date editors on the page.

Use the PopupCalendarOwnerID property to refer to a date editor control whose popup calendar should be used by the current editor. Note that if the PopupCalendarOwnerID property is set, the popup calendar’s settings are taken from the ASPxDateEdit.CalendarProperties property of the specified date editor. If the time edit is visible (the DateEditTimeSectionProperties.Visible is set to true) its settings are taken from the ASPxDateEdit.TimeSectionProperties property of the specified date editor.

Note

The PopupCalendarOwnerID property should not refer to a date editor whose PopupCalendarOwnerID property is also set.

Example

This example shows how to minimize the amount of rendered HTML code by using the same calendar control for every date editor within the ASPxGridView.

aspx
<dx:ASPxGridView runat="server" ID="Grid" AutoGenerateColumns="False" DataSourceID="AccessDataSource1" 
                 KeyFieldName="OrderID" OnAutoFilterCellEditorInitialize="Grid_AutoFilterCellEditorInitialize" OnCellEditorInitialize="Grid_CellEditorInitialize" OnRowUpdating="Grid_RowUpdating">
    <Columns>
        <dx:GridViewCommandColumn ShowEditButton="True" ShowClearFilterButton="True"/>
        <dx:GridViewDataTextColumn FieldName="OrderID" ReadOnly="True" >
            <EditFormSettings Visible="False" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataDateColumn FieldName="OrderDate" />
        <dx:GridViewDataDateColumn FieldName="RequiredDate" />
        <dx:GridViewDataDateColumn FieldName="ShippedDate" />
    </Columns>
    <Settings ShowFilterRow="True" />
</dx:ASPxGridView>

<dx:ASPxDateEdit runat="server" ID="__ReferenceDateEdit" ClientVisible="false">
    <CalendarProperties>
        <Style BackColor="LightYellow" />
    </CalendarProperties>
</dx:ASPxDateEdit>
csharp
protected override void OnLoad(EventArgs e) {
    base.OnLoad(e);
    if(!IsPostBack)
        Grid.StartEdit(0);
}
protected void Grid_RowUpdating(object sender, ASPxDataUpdatingEventArgs e) {
    e.Cancel = true;
}
protected void Grid_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridViewEditorEventArgs e) {
    SetupCalendarOwner(e.Editor as ASPxDateEdit);
}
protected void Grid_AutoFilterCellEditorInitialize(object sender, DevExpress.Web.ASPxGridViewEditorEventArgs e) {
    SetupCalendarOwner(e.Editor as ASPxDateEdit);
}
void SetupCalendarOwner(ASPxDateEdit editor) {
    if(editor == null) return;
    editor.PopupCalendarOwnerID = "__ReferenceDateEdit";
}
vb
Protected Overrides Sub OnLoad(ByVal e As EventArgs)
    MyBase.OnLoad(e)
    If Not IsPostBack Then
        Grid.StartEdit(0)
    End If
End Sub

Protected Sub Grid_RowUpdating(ByVal sender As Object, ByVal e As ASPxDataUpdatingEventArgs)
    e.Cancel = True
End Sub

Protected Sub Grid_CellEditorInitialize(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridViewEditorEventArgs)
    SetupCalendarOwner(TryCast(e.Editor, ASPxDateEdit))
End Sub

Protected Sub Grid_AutoFilterCellEditorInitialize(ByVal sender As Object, ByVal e As DevExpress.Web.ASPxGridViewEditorEventArgs)
    SetupCalendarOwner(TryCast(e.Editor, ASPxDateEdit))
End Sub

Private Sub SetupCalendarOwner(ByVal editor As ASPxDateEdit)
    If editor Is Nothing Then
        Return
    End If
    editor.PopupCalendarOwnerID = "__ReferenceDateEdit"
End Sub

See Also

Date Editor

ASPxDateEdit Class

ASPxDateEdit Members

DevExpress.Web Namespace