views:

37

answers:

3

I have an ASP.NET user control in which there are two fields (fromdate and todate) which have RequiredFieldValidators associated with them. When saving I want to validate if the fromdate and todate are entered. How do I do that? I have tried Page.IsValid, but it always returns true.

A: 

You can take a look at this example:

http://www.asp.net/ajax/ajaxcontroltoolkit/samples/maskededit/maskededit.aspx

Roger
A: 

there is some problem in your usercontrol required field validator. If the validation is working properly,if you not entered any value on the control it wont go to postback.

anishmarokey
A: 

The RequiredFieldValidator will obviously tell you if the controls have been populated, providing you have specified a ControlToValidate in them.

If you want to check whether they are valid dates then you would use the CompareValidator and set the DataType to be Date and then the Operator to DataTypeCheck.

You could also use a CompareValidtor to compare the two dates using ControlToValidate and ControlToCompare properties.

Mantorok