Friday, April 8, 2011

OnValidating Event in a custom control

When does the OnValidate event fire in the lifecycle of a control?

I'm creating a DateBox that will allow the user to enter a date in MM/DD/YYYY format (text) and need to verify that the date is in that format. It'll never be converted to a date (stored as string) but I would like to know the best time to validate that data (and provide feedback).

note: It may seem a bit like re-inventing the wheel, but the app that I'm writing gets deployed to a tablet-pc and the winforms DateTimePicker is hell to edit with a stylus and my users just want to be able to write in the date.

From stackoverflow
  • MaskedTextBox Control might help you.

    SnOrfus : You sir, are helpful :) Thank You.
  • OnValidate happens after the Loading events (source)

    You should validate on the client-side (javascript) AND server side either using the OnValidate or when handling the submission of the form (or both).

0 comments:

Post a Comment