使用方法很簡單,就不囉嗦那麼多了 翻譯過來就是 日曆擴充控制項吧 配合TextBox控制項使用只要TextBox獲的焦點就會顯示出來日曆
例子:只需要設定CalendarExtender的TargetControlID為需要顯示日期的TextBox的ID即可以,textBox控制項的readOnly屬性設定為 false
主要代碼:
- <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="True" EnableScriptLocalization="True">
- </asp:ScriptManager>
- <ajaxToolkit:CalendarExtender Format="yyyy-MM-dd" ID="CalendarExtender2"
- runat="server" TargetControlID="TextBox1" >
- </ajaxToolkit:CalendarExtender>
- <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
CalendarExtender的 Format屬性設定 時間的顯示格式
另:PopupButtonID屬性是設定一個button控制項的ID 點擊該控制項則展開calendarExtender
如下:
- <asp:ScriptManager ID="ScriptManager1" runat="server" EnableScriptGlobalization="True" EnableScriptLocalization="True">
- </asp:ScriptManager>
- <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1" PopupButtonID="ImageButton1" >
- </cc1:CalendarExtender>
- <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:ImageButton ID="ImageButton1"
- runat="server" />
ScriptManager的EnableScriptGlobalization屬性 和EnableScriptLocalization屬性設定為 true則 控制項為中文
具體ScriptManager的屬性方法還在學習中。