Ajax Calendar Extender问题

i have textbox in which i want to store the selected date of calender. for this purpose i have used calender extender. and set the target control property to textbox id. but when i click on button of same page then i lost the seleted date (i mean i lost the textvalue) but i want to the selected date after clicking on button.. my code is as

<td>
     <asp:TextBox ID="txtDate" runat="server" ReadOnly="true"></asp:TextBox>
</td>
 <td>
     <asp:ImageButton ID="imgCalender" runat="server" ImageUrl="~/Images/Calendar.png" ToolTip="Select a Date" />
   <asp:CalendarExtender ID="calShow"  runat="server" PopupButtonID="imgCalender" PopupPosition="BottomLeft" TargetControlID="txtDate" OnClientDateSelectionChanged="CheckForPastDate"></asp:CalendarExtender>
  </td>

and also i want when user try to select a date which is greater than the current date+20 days then text box should be empty. means user have to select again a proper date.

Javascript

var selectedDate = new Date(); 
selectedDate = sender._selectedDate; 
var todayDate = new Date(); 

if (selectedDate.getDateOnly() <= todayDate.getDateOnly()) 
{
    alert('Date Cannot be in the past or current date'); 
    sender._textbox.set_Value(null); 
} 
else if(selectedDate.getDateOnly() > todayDate.getDateOnly()) 
{
     // why is this here?
} 

within the js method just do something like

var today = new Date();
var twentyDays = new Date();
twentyDays.setDate(today.getDate()+20);

if (selectedDate.getDateOnly() <= todayDate.getDateOnly()) 
{
    alert('Date Cannot be in the past or current date'); 
    sender._textbox.set_Value(null); 
} 
else if(selectedDate.getDateOnly() > twentyDays.getDateOnly()) 
{
    alert('this is more than 20 days');
    sender._textbox.set_Value(null); 
    return;
}  

Update 02/12/2013

I am not sure what the getDateOnly() method is or does and that seemed to be causing me issues. The script below is what I put together to test scenarios and works. simply adjust the daysModifier variable to test.

var daysModifier = 23;
var selectedDate = new Date();
selectedDate.setDate(selectedDate.getDate() + daysModifier);

var today = new Date();
var twentyDays = new Date();
twentyDays.setDate(today.getDate()+20);

document.write(today);
document.write("<br />");
document.write(selectedDate);
document.write("<br />");
document.write(twentyDays);


if (selectedDate <= today) 
{
    alert('Date cannot be in the past or current date'); 
} 
else if(selectedDate > twentyDays) 
{
    alert('this is more than 20 days');
}