如何在ASP.Net Web窗体中使用Boostrap DateTimePicker [英] How to use Boostrap DateTimePicker in ASP.Net Web Form
问题描述
我试图在我的Asp.Net Web表单中使用Bootstrap datetimepicker
.单击该图标不会引发任何错误,但日历永远不会触发.我怎样才能在Asp.Net中使用它?由于这不是asp:控件,因此我没有在C#中创建一个_onClick()
函数,但是我是否需要在我的<script></script
中创建一个函数?这是我的代码:
I am trying to use a Bootstrap datetimepicker
in my Asp.Net web form. No errors are being thrown but the calendar never fires when I click on the icon. How can I get this to work in Asp.Net? Since this is not an asp: control, I'm not making an _onClick()
function in my C#, but do I need to make one in my <script></script
? Here's what my code looks like:
<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>
推荐答案
将ClientIDMode设置为静态"
set the ClientIDMode to "Static"
<input type='text' class="form-control" id="uxDateTimeLocalTextbox" value="" runat="server" ClientIDMode="Static" />
默认情况下,网络表单会更改呈现的html id. clientidmode会改变这种行为.
by default webforms change the rendered html id. clientidmode changes that behavior.
这篇关于如何在ASP.Net Web窗体中使用Boostrap DateTimePicker的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!