2013-08-12 22 views
2

我使用的是正常的AjaxControlToolkit &在我的頁面中使用2個datepicker。日期選擇器控件在窗體中使用AjaxControlToolkit(比較2日期選擇器)

第一個日期選擇器從當日日期(今天或任何先前日期)中取出不是日期的日期。在第二個文本框中,我可以選擇第一個日期選擇器中的日期到今日日期之間的日期。

我正在使用的腳本代碼適用於JQuery日期選擇器。但它在普通的Ajax日期選擇器中不起作用。

這裏的代碼如下:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %> 

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 
<head runat="server"> 
<title>Date Picker</title> 

<script type="text/C#" > 

$(function() { 
    $("#txtfrom").datepicker({ 
     onSelect: function (date) { 
      $("#txtto").datepicker({ 
       minDate: date, 
       maxDate: new Date() 
      }); 
     }, 
     maxDate: 0 
    }); 

}); 


</script> 
</head> 

<body> 
<form id="form1" runat="server"> 
<asp:ScriptManager ID="ScriptManager1" runat="server"> 
</asp:ScriptManager> 
<div> 
<b>From</b> 
<asp:TextBox ID="txtfrom" runat="server"></asp:TextBox> 
<cc1:CalendarExtender ID="ceLoanTakenDate" runat="server" Format="dd/MM/yyyy"  PopupButtonID="txtfrom" TargetControlID="txtfrom"> 
    </cc1:CalendarExtender> 
    &nbsp &nbsp 
    <b>To</b> 
    <asp:TextBox ID="txtto" runat="server"></asp:TextBox> 
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy" PopupButtonID="txtto" TargetControlID="txtto"> 
    </cc1:CalendarExtender> 


</div> 
</form> 
</body> 
</html> 

回答

0

您需要處理的第一個擴展的客戶端DateSelectionChanged事件,併成立了第二個擴展的startDate屬性:

<b>From</b> 
<asp:TextBox ID="txtfrom" runat="server"></asp:TextBox> 
<ajaxToolkit:CalendarExtender ID="ceLoanTakenDate" runat="server" Format="dd/MM/yyyy" 
    PopupButtonID="txtfrom" TargetControlID="txtfrom" 
    OnClientDateSelectionChanged="ceLoanTakenDate_dateSelectionChanged"> 
</ajaxToolkit:CalendarExtender> 
&nbsp;&nbsp; 
<b>To</b> 
<asp:TextBox ID="txtto" runat="server"></asp:TextBox> 
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd/MM/yyyy" PopupButtonID="txtto" 
    TargetControlID="txtto"> 
</ajaxToolkit:CalendarExtender> 

<script type="text/javascript"> 
    function ceLoanTakenDate_dateSelectionChanged(sender, args) { 
     $find("<%= CalendarExtender1.ClientID %>").set_startDate(sender.get_selectedDate()); 
    } 
</script> 
+0

腳本代碼我之前在頭部使用過,我必須使用或不使用的代碼。 @Yuriy Rozhovetskiy – Sabyasachi

相關問題