AJAX Control Toolkit - Calendar(弹出式日历)

虽然不使用Ajax Contorl Toolkit也能实现该效果,当然如果使用ASP.NET中自带的Calendar要解决异步刷新还要配合UpdatePanel使用。但或许该控件对多数人还是相对容易些。首先对该控件的一些常用属性做一下基本的了解:

TagetControlID - 一般是TextBox的 ID.

CSSClass - Name of the Cascading Style Sheet class Use to style the calendar.

DaysModeTitleFormat - Format string used to display Days Mode Title.The default value is "MMMM,yyyy".(ex:August,2011)

DefaultView - Gets or sets the default view of the calender.The default value is Days.(可以设置为 Moths or Years)

Format - Format string used to display the selected date.The default value is "d"(ex:8/11/2011).(and "yyyy年MM月dd日"(2011年8月8日),"yyyy-MM-dd"(2011-8-8))

PopupButtonID - The ID of a control to show the calendar popup when clicked. If this value is not set, the calendar will pop up when the textbox receives focus. (可以用ImageButton或者image标签来作为PopupButton)         

PopupPosition - Gets or sets the popup position of the calendar. The default value is BottomLeft.

SelectedDate - Gets of Sets the data the calendar is initialized with.(初始化的日期)

TodaysDateFormat - Format string used to display today's date.The default value is "MMMM d,yyyy"

{说明:弹出式日历是在TargetControl聚焦(Focus)时,弹出,如果设置了PopupButtonID时,点击该控件时弹出日历}

 1   <asp:ScriptManager ID="ScriptManager1" runat="server" />
2 <div>
3 <br /><br />
4 <b>Default Calendar:</b><br />
5 <asp:TextBox ID="Date1" runat="server"></asp:TextBox>
6 <ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server"
7 ClearTime="true"
8 TargetControlID="Date1" SelectedDate="8/08/2011">
9 </ajaxToolkit:CalendarExtender>
10 <br /><br />
11 <b>Calendar with Custom Style and Date Format:</b><br />
12 <asp:TextBox ID="Date2" runat="server"></asp:TextBox>
13 <ajaxToolkit:CalendarExtender ID="CalendarExtender2" runat="server" TargetControlID="Date2" CssClass="MyCalendar" Format="yyyy年MM月dd日">
14 </ajaxToolkit:CalendarExtender>
15 <br /><br />
16 <b>Calendar with associated button:</b><br />
17 <asp:TextBox ID="Date3" runat="server"></asp:TextBox>
18 <asp:Image ID="Image1" runat="server" ImageUrl="~/Calendar_scheduleHS.png" />
19 <ajaxToolkit:CalendarExtender ID="CalendarExtender3" runat="server" TargetControlID="Date3" PopupButtonID="Image1" DaysModeTitleFormat="yyyy年,MM月" Format="yyyy-MM-dd" DefaultView="Days">
20 </ajaxToolkit:CalendarExtender>

  

你可能感兴趣的:(calendar)