Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Custom Validator
Message
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
01057025
Message ID:
01057498
Views:
24
>>>>>>Hi All,
>>>>>>
>>>>>>I have a web form with 3 textboxes to receive dates also I have a custom validator and a method (validate_date) to validate one of the dates.
>>>>>>
>>>>>>private void Validate_date( object sender, ServerValidateEventArgs e)
>>>>>>{
>>>>>>			lblMessage.Text = "";
>>>>>>			e.IsValid = true;
>>>>>>			
>>>>>>			if ( !IsDate( e.Value) )
>>>>>>			{
>>>>>>				e.IsValid = false;
>>>>>>				
>>>>>>				cv_IssuedDate.ErrorMessage = "Invalid Date!";
>>>>>>				lblMessage.Text = "Issued Date Invalid";
>>>>>>			}
>>>>>>		}
>>>>>>
>>>>>>		public bool IsDate(string sdate)
>>>>>>		{
>>>>>>			DateTime dt;
>>>>>>			bool isDate = true;
>>>>>>			try
>>>>>>			{
>>>>>>				dt = DateTime.Parse(sdate);
>>>>>>			}
>>>>>>			catch (Exception e)
>>>>>>			{
>>>>>>				isDate = false;
>>>>>>				lblMessage.Text = e.Message;
>>>>>>			}
>>>>>>			return isDate;
>>>>>>		}
>>>>>>
>>>>>>The problem is that is always returning Invalid date even when I type a correct date
>>>>>>Ex 01/01/01 or 01/01/2000
>>>>>>
>>>>>>Any help would appreciated,
>>>>>>
>>>>>>thanks
>>>>>
>>>>>William,
>>>>>
>>>>>Have you looked at what the date format settings are on your computer through the Control Panel?
>>>>
>>>>Hi Gearge,
>>>>
>>>>thanks for your reply. This is the display format mm/dd/yyyy.
>>>
>>>Why not use System.Convert.ToDateTime()?
>>
>>Hey George,
>>Now it's not firing at all the custom method:
>>these are the properties set for the custom validator:
>>
>>ID:cvIssuedDate
>>ControlToValidate: txtIssuedDate
>>Display: Dynamic
>>ErrorMessage: Enter issued Date
>>ServerValidate: Validate_date (this is the custom method posted above )
>>
>>Any ideas?
>>
>>Thanks in advance.
>
>How about the CausesValidation property? That wouldn't be set to false, would it? Or the CancelEventArgs's Cancel property?


I have tow buttons: btnSave and btnCancel.
CausesValidation properyt is set to true only in the Save button.
In which control is CancelEventArgs?
Previous
Reply
Map
View

Click here to load this message in the networking platform