我正在尝试在我的Asp.Net Web表单中使用Bootstrap datetimepicker
。单击该图标不会引发任何错误,但日历永远不会触发。如何在Asp.Net中使用它?由于这不是asp:控件,因此我没有在C#中创建一个_onClick()
函数,但是我需要在<script></script
中创建一个函数吗?这是我的代码:
<link href="http://ajax.aspnetcdn.com/ajax/jquery.ui/1.9.1/themes/start/jquery-ui.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/css/bootstrap-datetimepicker.min.css" />
...
<script src="https://code.jquery.com/jquery-1.9.1.js"></script>
<script src="https://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.0/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.6/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootstrap-datetimepicker/4.17.37/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(function() {
$('#uxDateTimeLocalTextbox').datetimepicker();
});
});
</script>
<body>
....
<div class="container">
<div class='col-md-5'>
<div class="form-group">
<div class='input-group date' >
<input type='text' class="form-control" id="uxDateTimeLocalTextbox" value="" runat="server"/>
<span class="input-group-addon">
<span class="glyphicon glyphicon-calendar"></span>
</span>
</div>
</div>
</div>
</div>
</body>
答案 0 :(得分:1)
将ClientIDMode设置为“静态”
<input type='text' class="form-control" id="uxDateTimeLocalTextbox" value="" runat="server" ClientIDMode="Static" />
默认情况下,网络表单会更改呈现的html id。 clientidmode会改变这种行为。
答案 1 :(得分:1)
Please try this code
<div class="row">
<label class="col-md-4 control-label"> From Date</label>
<div class='input-group ' id='FromDate' data-date-format="dd-mm-yyyy" style="width: 132px;">
<input type='text' class="form-control" id="txtFromDate" onchange="txtFromDate_change();" />
<span class="input-group-addon"><span class="fa fa-calendar fa_cal"></span></span>
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$("#FromDate").datepicker({
autoclose: true,
todayHighlight: true,
orientation: 'auto bottom'
});
});
</script>