Validate the DateTimePicker Control in silverlight page

To Block,entering alphabets and other characters in TextBlock Of the DateTime Control in Silverlight Page

private void txtToDate_KeyDown(object sender, KeyEventArgs e)
if ((e.Key < Key.D0 || e.Key > Key.D9) && (e.Key < Key.NumPad0 || e.Key > Key.NumPad9) && (e.PlatformKeyCode != 191))
e.Handled = true;

this code only allow to enter nubers and backslashes.
For ex:01/01/2010


No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: