views:

207

answers:

2

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.

+1  A: 

MaskedTextBox Control might help you.

Canavar
You sir, are helpful :) Thank You.
SnOrfus
+1  A: 

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).

GoodEnough