Best way to auto-insert date delimiter slashes

4 posts, 0 answers
  1. Ian
    Ian avatar
    51 posts
    Member since:
    Apr 2009

    Posted 01 Mar 2011 Link to this post

    I'm looking at how to auto-insert slashes as the user enters data into the text box part of the DateTimePicker control, but can't see an easy way to do this.
    Too many properties are read only and if I try and set the value of the control in an event like ParseDateTimeValue the rest of the input then gets set to a valid date.

    eg imagine the user wants to enter a date of 10/12/2010  as soon as they've entered "10" I want the input text box to display "10/" and have the cursor positioned ready for the month NOT have it switch in today's month and year with the cursor positioned at the end, which is what happens even if I don't go anwhere near the args.Result parameter that ParseDateTimeValue gives me to play with.

    In many ways a MaskedTextBox offers something similar to what I want except our end-users don't want to use cursor keys to move between the slash delimiters.

    Is there an easy way to implement what is required?
  2. Kaloyan
    Kaloyan avatar
    920 posts

    Posted 02 Mar 2011 Link to this post

    Hello Ian,

    Currently the control doesn't support the required functionality. A better choice would be using the RadMaskedTextBox.

    the Telerik team
    Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
  3. Mike
    Mike avatar
    4 posts
    Member since:
    Jun 2009

    Posted 02 Jun 2011 Link to this post


    I need to do the same thing with this control, did you manage to resolve the issue?


  4. Miroslav Nedyalkov
    Miroslav Nedyalkov avatar
    1718 posts

    Posted 08 Jun 2011 Link to this post

    Hi Mike,

     This behavior is by design - we wanted to provide a free text input DateTimePicker control that allows the user to input arbitrary text instead of masked input.
     I would suggest you the same thing that Kaloyan suggested - to use the RadMaskedTextBox control instead. If you need to show the button with the calendar and clock you may use the RadDropDownButton control, the RadCalendar control and the RadClock control with the RadMaskedTextBox (the same we did in the RadDateTimePicker, but with another TextBox).

    Hope this helps.

    Miroslav Nedyalkov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top