[英]Calendar control in asp.net c#
I need to add a calendar control with its associated buttons in asp.net with C#. 我需要使用C#在asp.net中添加一个日历控件及其关联的按钮。
I have the code as below. 我有下面的代码。
<asp:TextBox ID="txtDateFrom" CssClass="text-small" runat="server"
BorderWidth="1px" ToolTip="Click to choose date"></asp:TextBox>
<asp:Label ID="lblFromError" CssClass="Error" runat="server"
Text="*" Visible="False"></asp:Label>
<asp:Label ID="lblTo" runat="server" Text="To" ForeColor="Black"></asp:Label>
<asp:CalendarExtender ID="txtDateFrom_CalendarExtender" runat="server"
TargetControlID="txtDateFrom"
Format="yyyy-MM-dd" TodaysDateFormat="yyyy d, MMMM">
</asp:CalendarExtender>
you can use the JQuery plugin for Calendar. 您可以将JQuery插件用于Calendar。 Check this topic
检查这个话题
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script>
$(document).ready(function() {
$("#datepicker").datepicker();
});
</script>
<div type="text" id="datepicker"></div>
You will need to add an ImageButton and set the CalendarExtender
's PopupButtonID
property to the ID of the ImageButton. 您将需要添加一个ImageButton并将
CalendarExtender
的PopupButtonID
属性设置为该ImageButton的ID。
This is from the AjaxControlToolkit's sample web site: 这是来自AjaxControlToolkit的样本网站:
<ajaxToolkit:ToolkitScriptManager runat="Server" ID="ScriptManager1" />
<b>Calendar with an associated button:</b><br />
<asp:TextBox runat="server" ID="Date5" />
<asp:ImageButton runat="Server" ID="Image1"
ImageUrl="~/images/Calendar_scheduleHS.png"
AlternateText="Click to show calendar" /><br />
<ajaxToolkit:CalendarExtender ID="calendarButtonExtender" runat="server"
TargetControlID="Date5" PopupButtonID="Image1" />
Do like this 1. Add a ToolkitScriptManager 2. Add a TextBox Control 3. Add a CalendarExtender 做到这一点1.添加一个ToolkitScriptManager 2.添加一个TextBox控件3.添加一个CalendarExtender
Here is the complete code : 这是完整的代码:
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager>
<asp:TextBox ID="txtStartDate" runat="server"></asp:TextBox>
<asp:CalendarExtender
ID="CalendarExtender1"
TargetControlID="txtStartDate"
runat="server" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.