2010-02-10 35 views
2

我使用AJAX日曆擴展如下。我想突出顯示一個特定的日期時,打開AJAX日曆彈出

*日期

<asp:TextBox ID="txtCalControl" runat="server" Visible="True" Enabled="false" 
CssClass="inputText" ErrorKey="IsValidDate" ></asp:TextBox> 
<span > 
<asp:Image ID="imbCaledar" runat="server" ImageUrl="~/Images/calendar.GIF" /> 
</span> 
</td> 
<td > 
<ajaxToolkit:CalendarExtender ID="calDisplaydate" runat="server" TargetControlID="txtCalControl" PopupButtonID="imbCaledar" PopupPosition="BottomRight" > 
</ajaxToolkit:CalendarExtender> 
</td> 

我想日曆設置爲特定的日期(例如2007年2月14日),當用戶點擊了圖片。

我試着在.cs中選擇日期屬性,但它將值賦給文本框。

以下是我必須實現

字段爲空的要求,並且不顯示任何日期作爲默認設置。用戶需要選擇一個日期來填充該字段。因此,該字段爲空,直到用戶從日曆中選擇日期。

默認情況下,打開時的日曆控件設置爲2年前的當前日期。

回答

1

您可以使用OnClientDateSelectionChanged處理程序與設置BehaviorID結合,從而可以找到擴展容易:

<ajaxToolkit:CalendarExtender ID="calDisplaydate" runat="server" 
TargetControlID="txtCalControl" PopupButtonID="imbCaledar" 
PopupPosition="BottomRight" OnClientDateSelectionChanged="setDate" 
BehaviorID="myDate"> 
</ajaxToolkit:CalendarExtender> 

在javascript中:

<script type="text/javascript" language="javascript"> 
     function setDate(sender,args){ 
     var d = new Date(); //Today 
     d.setYear(d.getYear() - 2); //2 years ago 
     $find("myDate").set_selectedDate(d); 
     } 
    </script> 
+0

非常感謝尼克..這工作 – SaveMe 2010-02-12 13:04:44

相關問題