代码之家  ›  专栏  ›  技术社区  ›  gwydion93

如何在ASP中使用Boostrap DateTimePicker。网络表单

  •  0
  • gwydion93  · 技术社区  · 6 年前

    我正在尝试使用引导 datetimepicker 在我的Asp。Net网页表单。没有抛出任何错误,但当我点击图标时,日历不会触发。我怎样才能让它在Asp中工作。网因为这不是一个asp:control,所以我不打算 _onClick() 函数在我的C#中,但我需要在我的 <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 回复  |  直到 6 年前
        1
  •  1
  •   Stephen Wrighton    6 年前

    将ClientMode设置为“静态”

    <input type='text' class="form-control" id="uxDateTimeLocalTextbox" value="" runat="server" ClientIDMode="Static" />
    

    默认情况下,webforms会更改呈现的html id。clientidmode会更改该行为。

        2
  •  1
  •   usha    6 年前
    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>