Computer Magic Logo
Date Picker

Sunday, June 7, 2015

Published by Aristotelis Pitaridis

Date Picker is an input control that allows the administrator to enter a date. Below we can see an example of creating a property of type Date Picker:

The My Date Picker property has the following appearance when we edit the document:

If you click on the calendar icon on the right side of the text box a panel which contains a calendar will appear on the screen where we can select a date.

In order to read the value as a strongly typed object we use the following code:

@{
    if (Model.Content.HasValue("myDatePicker"))
    {
        <p>@(Model.Content.GetPropertyValue<string>("myDatePicker"))</p>
    }
}

In order to read the value using dynamic properties we use the following code:

@{
    if (CurrentPage.HasValue("myDatePicker"))
    {
        <p>@CurrentPage.myDatePicker</p>
    }
}