I'm doing some Sharepoint webparts and i'm trying to use a jquery datetimepicker, but i can't quite retrieve the value from the datetimepicker in the C# code behind. Here is my script :
<input type="hidden" id="StartDateHiddenField" name="StartDateHiddenField" value=""/>
<script type="text/javascript">
$(document).ready(function () {
$(".datepicker1").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "dd-mm-yy",
showButtonPanel: false,
onClose: function (dateText, inst) {
$(this).datepicker('setDate', new Date(inst.selectedYear, inst.selectedMonth, 1));
$('#StartDateHiddenField').val($(this).datepicker("getDate"));
}
});
});
</script>
In code behind :
var test = Page.Request.Form["StartDateHiddenField"];
var startTime = DateTime.Parse(Page.Request.Form["StartDateHiddenField"]);
test value according to debugger is, for exemple :
"Sat Jul 01 2017 00:00:00 GMT+0200 (Romance Daylight Time)"
How can i get proper values from DateTime.Parse ?
感谢ADyson,一个解决方案是使用$(this).datepicker("getDate").toISOString()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.