Link to home
Start Free TrialLog in
Avatar of suresh pondicherry
suresh pondicherryFlag for United States of America

asked on

Avoid typing in Datepicker text

Hi All,
Advance thanks.
I am using Datepicker control in UI. Would need to restrict user only to select the date from the dropdown calender. Now when the user types in any characters in the text, it get stayed and i don't know how to clean the text. Is there any way to restrict the user not to type in anything in the text area.

Kind regards,
Pooja
ASKER CERTIFIED SOLUTION
Avatar of Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger)
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of suresh pondicherry

ASKER

Excellent.
Hi James,
It is working fine  for first time. I mean, it is disallowing the user not to type in anything in the  text first. But allow them to enter text after the date is picked from the calendar.

Kind regards,
Pooja
You added something somewhere.

Attached is a simple form that shows the concept, and they cannot type in even after making a selection. Form1.zip
Hi James,
Am using SL4. This is my code

   Private Sub DateTimePicker_KeyPress(ByVal sender As Object, ByVal e As KeyEventArgs)
        If Not e.PlatformKeyCode = 9 Then e.Handled = True
    End Sub

Kind regards,
Pooja

The code would be the same.

If the keypress cancels everything except a tabulation (that is what the 9 stands for, isn't it?) before selecting a date, it should continue to do the same after.

If you put a breakpoint in the KeyPress, is it still hit after the selection?

If so, there is no reason why the code would not still work.

If not, then something broke the link between the event and the event procedure. I am sorry, but I do not know how the procedure is linked to the event in Silverlight.