devexpressdevexpress-windows-uidevexpress-mvc

On the DevExpress DateEditFor control, how to force date selection only by clicking in the calendar and never manually entered


In the MVC DevExpress DateEditFor, (composed of a text box and a drop down popup calendar) is there a way to disable the user from entering the date directly in the text box thus forcing the selection to be only by clicking in the calendar ?

@Html.DevExpress().DateEditFor(m => m.StartDateReserv, settings =>
{
    settings.Properties.CalendarProperties.FastNavProperties.Enabled = false;
    settings.Properties.AllowNull = true;
    settings.Properties.MinDate = DateTime.Today;
    settings.Properties.EditFormat = EditFormat.Date;
    settings.Properties.DisplayFormatString = "d";
    settings.Properties.ShowOutOfRangeWarning = false;
    settings.ShowModelErrors = false;

    settings.Properties.CalendarProperties.ShowClearButton = false;
    settings.Properties.CalendarProperties.ShowTodayButton = false;
    settings.Properties.CalendarProperties.ShowWeekNumbers = false;
    settings.Properties.CalendarProperties.EnableYearNavigation = false;
    settings.Properties.ClientSideEvents.GotFocus = "function(s, e) { s.ShowDropDown(); }";
 }).GetHtml()

Solution

  • You should be able to accomplish this with the following setting:

     settings.Properties.AllowUserInput = false;