I have scenario, Page contains Check in date and Check out date for input. I used user control for datepicker, so both dates are called same user control.
Like,
Check In Date: <uc:datepicker ID="CheckInDate" runat="server" />
Check Out Date: <uc:datepicker ID="CheckOutDate" runat="server" />
Now I do validation for both dates which should not be blank like.
public class CustomiseDatePickerValidator : BaseValidator
{
protected override bool EvaluateIsValid()
{
Control c = this.FindControl(this.ControlToValidate);
DatePicker datepickerSelected = c as DatePicker;
ICustomiseRadDatePicker additionUserControl = (ICustomiseRadDatePicker)c.Parent;
if (string.IsNullOrEmpty(datepickerSelected.DateInput.Text))
{
return false;
}
return true;
}
}
This is working fine but I want also compare both datepicker value So Check in date Should be less than Check out date
It would probably be easier to use a
CustomValidatorfor this. With theCustomValidator, you can specify your own client-side validation logic.See this question for more details:
ASP.NET Custom Validator Client side & Server Side validation not firing