我正在使用daterangepicker,并在以下代码的帮助下创建了一个asp.net webform
<script type="text/javascript">
$(function () {
$('#calendar').datetimepicker({
format: 'L',
inline: true
});
});
</script>
<div id="calendar" style="width: 100%"></div>
<asp:HiddenField ID="HiddenField1" runat="server" />
我想在asp.net隐藏字段
中显示选定的日期试试下面的代码。
$(function() {
$('#calendar').datetimepicker({
format: 'L',
inline: true
});
});
$("#calendar").on("dp.change", function (e) {
alert(e.date);
$('#HiddenField1').val(e.date);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap/5.1.3/css/bootstrap.min.css" />
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.47/css/bootstrap-datetimepicker.css" />
<div id="calendar" style="width: 100%"></div>
<asp:HiddenField ID="HiddenField1" runat="server" />