使用ASP.Net和C#
我想在我的网页中使用datetimepicker,但我找不到控件,如何在网页中获取datetime picker控件。
可以提供任何示例代码。
需要C#代码帮助。
发布于 2010-08-10 15:39:59
如果您不介意使用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>使用如下代码所示的插件
// date and time
$('input').datetimepicker({...});
// or just time
$('input').timepicker({...});编辑:(将urls添加到javascript文件)
可以从以下urls下载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>发布于 2010-08-10 15:37:48
我在我的页面上使用jQuery日期选择器。你可以看看http://jqueryui.com/demos/datepicker/。
它的用途是,您只需在c#/asp.net页面中定义一个普通的文本框,然后在客户端添加所有的日期选择函数。
在网页上,你至少会有这部分代码:
</script>
$(function() {
$("#YourTextBoxId").datepicker();
});
</script>你可以在这里找到一个有效的演示:http://jqueryui.com/demos/datepicker/default.html
发布于 2010-08-10 15:44:11
您可以结合使用ASP、.NET AJAX日历扩展器和标准textbox控件。
请参阅示例here
一旦你安装了Ajax工具包(download from here),就需要在你的网页中添加三行代码:
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"> </asp:ToolkitScriptManager>
<asp:TextBox runat="server" id="txtCalendar"></asp:TextBox>
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtCalendar"></asp:CalendarExtender>https://stackoverflow.com/questions/3446922
复制相似问题