Javascript:
<script type="text/javascript">
$(function() {
$("#<%= txtFrom.ClientID %>").datepicker({
showmonth:true,
autoSize: true,
showAnim: 'slideDown',
duration: 'fast'
});
$("#<%= ImageButton1.ClientID %>").click(function() {
$("#<%= txtFrom.ClientID %>").datepicker('show');
});
});
</script>
コード:
<asp:TextBox ID="txtFrom" MaxLength="10" runat="server" ToolTip="Enter From Date">
</asp:TextBox>
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Images/clock_add.gif" />
参照jqueryフォーラム
編集1
この機能を変更する
$("#<%= ImageButton1.ClientID %>").click(function() {
$("#<%= txtFrom.ClientID %>").datepicker('show');
});
に
$("#<%= ImageButton1.ClientID %>").click(function() {
$("#<%= txtFrom.ClientID %>").datepicker('show');
return false;
});
また
$("#<%= ImageButton1.ClientID %>").click(function(event) {
$("#<%= txtFrom.ClientID %>").datepicker('show');
event.preventDefault();
});
編集2
$("#txtStartDate").datepicker({
showOn: "both",
onSelect: function(dateText, inst){
$("#txtEndDate").datepicker("option","minDate",
$("#txtStartDate").datepicker("getDate"));
}
});
ソース:
別の日付ピッカーまたはテキストボックスに基づいてjquerydatepickerの日付を制限する