改變作爲的TargetControlID爲CalendarExtender文本框的值會影響所選日期如果滿足以下2個條件得到滿足:
- 一種平變化事件上的文本框中燒製(通過手動改變所述文本或通過調用的顯式的JavaScript fireEvent()方法。
- 的格式在文本框中輸入的日期與CalendarExtender控件使用的格式相匹配。
話雖這麼說,來處理這個正確的方法是調用CalendarExtender控制的set_selectedDate()
功能。這一次調用不僅可以在日曆上設置選定的內容,還可以同時在「目標」文本框中設置。
這裏的示例代碼:
<cc1:CalendarExtender ID="CalendarExtender1" runat="server"
OnClientDateSelectionChanged="dateSelectionChanged"
TargetControlID="txtDate" PopupButtonID="imgCalendar">
</cc1:CalendarExtender>
<script type="text/javascript">
function dateSelectionChanged(sender, args){
selectedDate = sender.get_selectedDate();
/* replace this next line with your JS code to get the Sunday date */
sundayDate = getSundayDateUsingYourAlgorithm(selectedDate);
/* this sets the date on both the calendar and textbox */
sender.set_SelectedDate(sundayDate);
}
</script>
在那裏你爲什麼選擇使用這個日曆控件,而不是jQuery的日期選擇器插件的原因嗎? – TStamper 2009-05-05 14:14:59
我選擇使用這個日曆控件,因爲我在ASP.Net中開發,我們必須限制我們使用的東西。我們的項目中已經有了Ajax控件工具包,所以我必須堅持這一點。 – Miles 2009-05-05 14:41:45