Hello,
I have a standard DateTimePicker control and I'd like to have a custom validator (server side) against it, something like this:
and on the server:
Now, the problem is that in this setup, args.value is looking like this: "2010-02-27-15-00-00" and this will not parse thru DateTime.TryParse (or at least I have not found a proper combination of culture and DateTimeStyles settings that will parse this string).
My question is - is there any way to modify value property of DateTimePicker so it will produce string that will parse thru DateTime.TryParse ?
Thanks,
Antonin
I have a standard DateTimePicker control and I'd like to have a custom validator (server side) against it, something like this:
<telerik:RadDateTimePicker ID="picker1" runat="server" SelectedDate="<%#((DateTime)((DataRowView)Container.DataItem)[1])%>" > |
<DateInput DateFormat="d.M.yyyy H:mm" DisplayDateFormat="d.M.yyyy H:mm" /> |
<TimeView StartTime="10:0:0" EndTime="21:01:00" Interval="0:15:0" Columns="7" TimeFormat="HH:mm" Culture="cs-CZ" /> |
</telerik:RadDateTimePicker> |
<asp:CustomValidator ID="custValCasVykopu" runat="server" ControlToValidate="picker1" Display="dynamic" Text="Enter correct date and time" OnServerValidate="custValCasVykopu_Validate" /> |
and on the server:
protected void custValCasVykopu_Validate(object source, ServerValidateEventArgs args) |
{ |
string txtCasVykopu = args.Value; |
DateTime casVykopu; |
if (DateTime.TryParse(txtCasVykopu, out casVykopu)) |
{ |
args.IsValid = true; |
} |
else |
{ |
args.IsValid = false; |
} |
} |
Now, the problem is that in this setup, args.value is looking like this: "2010-02-27-15-00-00" and this will not parse thru DateTime.TryParse (or at least I have not found a proper combination of culture and DateTimeStyles settings that will parse this string).
My question is - is there any way to modify value property of DateTimePicker so it will produce string that will parse thru DateTime.TryParse ?
Thanks,
Antonin