c# - 如何使用日期时间选择器

标签 c# .net asp.net

使用 ASP.Net 和 C#

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

能否提供示例代码。

需要 C# 代码帮助。

最佳答案

如果您不介意使用 jQuery,您可以只使用文本框并将其转换为带有 jQ​​uery 的日期和时间选择器。

关于如何在 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>

使用如下代码所示的插件

// date and time
$('input').datetimepicker({...});
// or just time
$('input').timepicker({...});

编辑:(将 url 添加到 javascript 文件)

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>

关于c# - 如何使用日期时间选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3446922/

相关文章:

c# - .Net 的 Blackmagic Decklink 接口(interface)

c# - 如何使用 C# 获取多行文本框中的 LineHeight/FontHeight?

c# - 错误 CS0234 : The type or namespace name 'CustomMarshalers' does not exist in the namespace 'System.Runtime.InteropServices'

c# - 从堆栈跟踪创建错误号

c# - LINQ to SQL 加载

c# - 通过 C# 在 outlook 中打开发送电子邮件对话框

c# - 获取动态创建的图像按钮 ID (C#)

c# - DDD实践: Should I create a repository for value objects

.net - 有没有办法使用 ReSharper 自动生成 GetHashCode 和 Equals?

c# - 如何在 jQuery 中调用 C# 方法?