如何使用日期时间选择器

Gop*_*pal 1 .net c# asp.net

使用ASP.Net和C#

我想在我的网页中使用datetimepicker,我找不到控件,如何在网页中获取日期时间选择器控件.

可以提供示例代码.

需要C#代码帮助.

Wou*_*ens 5

如果您不介意使用jQuery,可以使用文本框并使用jQuery将其转换为日期和时间选择器.

关于如何在jQuery网站上使用的更多解释:http: //plugins.jquery.com/project/timepicker-addon

只需在页面中包含3个javascript引用

<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-1.8.custom.min.js"></script>
<script type="text/javascript" src="js/jquery-ui-timepicker-addon-0.5.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

使用插件,如下面的代码所示

// date and time
$('input').datetimepicker({...});
// or just time
$('input').timepicker({...});
Run Code Online (Sandbox Code Playgroud)

编辑:(添加到JavaScript文件的URL)

Javascript文件可以从以下网址下载:

http://trentrichardson.com/examples/timepicker/js/jquery-1.4.2.min.js

http://trentrichardson.com/examples/timepicker/js/jquery-ui-1.8.custom.min.js

http://trentrichardson.com/examples/timepicker/js/jquery-ui-timepicker-addon-0.5.min.js

额外的例子:

<div class="example-container">
  <p>Show time in AM/PM 12 hour format</p>
  <div>
     <input type="text" id="example2" value="" />
  </div>
  <script type="text/javascript">
    $('#example2').datetimepicker({ampm: true});
  </script>
</div>
Run Code Online (Sandbox Code Playgroud)