Exception is :
Operation failed String was not recognized as a valid DateTime.
Here is the jQuery reference
<script src="Resource/JS/jquery-1.7.2.min.js" type="text/javascript"></script>
<link href="Resource/css/jquery-ui-1.8.21.custom.css" rel="stylesheet" type="text/css" />
<script src="Resource/JS/jquery-ui-1.8.21.custom.min.js" type="text/javascript"></script>
The function to pop-up DatePicker:
function showDatePicker(datepicker) {
var id = "#" + datepicker;
$(function () {
$(id).datepicker();
});
}
</script>
The input component:
<input id="tbActionDate" type="text" runat="server" class="datePickerControl" clientidmode="Static" onclick="showDatePicker('tbActionDate');" />
And I have tried to do it in this way: $(id).datepicker(“option”, “dateFormat”, “mm/dd/yy”);
It doesn’t work.
I finally figured it out. It wasn’t because of the jQuery DatePicker, but the Convert.ToDateTime() in .NET cannot handle the date format (mm/dd/yyyy).
So I wrote my own method to convert it to the right object of DateTime.
Do you guys have any solutions to convert this date format to an object of DateTime in C#?
I’ve tried to use the CultureInfo to get the local culture object and used it to be a parameter in the Convert.ToDateTime() method, but it doesn’t work.