custom validator
-
how can i check if a user supplied date is before the current date? if this occur, i want to show a message about the error. i`ve tried with a custom validator and made the test within the server validate event handler of the control. but it didn`t work. the code is shown below:
private void cvDtInAt_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) { if(DateTime.Parse(txtDataInicio.Text) < DateTime.Now) args.IsValid = false; }
also, i`m showing a error summary with the errors occured (as a textbox). i`m using VS2003 and ASP.NET 1.1 thanks in advance... (: -
how can i check if a user supplied date is before the current date? if this occur, i want to show a message about the error. i`ve tried with a custom validator and made the test within the server validate event handler of the control. but it didn`t work. the code is shown below:
private void cvDtInAt_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) { if(DateTime.Parse(txtDataInicio.Text) < DateTime.Now) args.IsValid = false; }
also, i`m showing a error summary with the errors occured (as a textbox). i`m using VS2003 and ASP.NET 1.1 thanks in advance... (: -
I'm guessing that you are already validating that the text can be converted to a DateTime value. You also might want to DateTime.Today Is the validation firing?
yes... it`s firing... i have already validating if the text can be converted to a DateTime, but using another validator, not this one. the question is... even if i set de argument`s IsValid property... it still doesn`t show the error in the error summary... have you got it now?
-
how can i check if a user supplied date is before the current date? if this occur, i want to show a message about the error. i`ve tried with a custom validator and made the test within the server validate event handler of the control. but it didn`t work. the code is shown below:
private void cvDtInAt_ServerValidate(object source, System.Web.UI.WebControls.ServerValidateEventArgs args) { if(DateTime.Parse(txtDataInicio.Text) < DateTime.Now) args.IsValid = false; }
also, i`m showing a error summary with the errors occured (as a textbox). i`m using VS2003 and ASP.NET 1.1 thanks in advance... (:are you validating the controls on server side or client side?
Pankaj Gupta (Take it easy)