Rad DateTimePicker - Invalid Date Format Exception

Diana

I use a Rad DateTimePicker in a certain application. What I want to achieve is to get the date that the user selects, along with the time of course, and send those using JScript to an asmx webservice as one of its arguments. What I did was that I sent the datetime as string from the JScript file and in the webservice I tried to parse that string back to datetime format using convert.todatetime method and I tried several other conversion methods but my problem was always one; and that is the string that's being sent is not recognized as a correct "convertible" datetime.

I debugged, and it's always sent as, for example, "2012-12-13-08-02-05" [this corresponds to 13/12/2012 08:02:05]. As you can see, this string really is not in one of the acceptable formats that the parsing methods accept.

I tried to change the input dateformat of the datetimepicker and it does change but only in displaying; it does not change in the string according to what I want [I mean the format I set is reflected on display only and not on save].

I'd really appreciate your help, thank you.

Peter

The type of RadDateTimePicker's Value property is DateTime. You should parse manually your XML/Text date to the .NET type DateTime and pass the result to the Value property and vice versa - you should manually compose the desired output format from the Value property (which is .NET type DateTime)

Diana

When I debug, I find that the "SelectedDate" variable type here is "String". And it's in the format I mentioned before, that is for example, "2012-12-13-08-02-05" [corresponding to 13/12/2012 08:02:05]. And after sending this value to the asmx webservice end, it's received in the same format: "2012-12-13-08-02-05" [corresponding to 13/12/2012 08:02:05].

When, in the webservice, I write:

Dim_FormattedDate AsDatetime = Convert.ToDateTime(SelectedDate)

I get an error when I run this that the received String, that is "SelectedDate" is not recognized to be in a valid Datetime format.

My question, put in another way, would be: is there any way to manipulate the String that is produced from "dpTest.val()" in the first place to be in a valid recognizable Datetime format? To be specific, in the format "dd/MM/yyyy HH:mm:ss"?

Thanks again!

Peter

As I mentioned before you should parse manually the date in your format to DateTime. I am not sure that Convert.ToDateTime can work with your format - you can refer to this code project article to see how to convert manually your format.

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.