Change the calenderextender default date
I have FROM DATE and TO DATE in a web form both are using the ajax calenderextender. When users select the FROM开发者_JAVA百科 DATE and I want to default the TO DATE calenderextender date to FROM DATE +2 days. Is there any way to achieve this?
Thanks
You can use javascript to set the SelectedDate
property of "To Date" Calendar in OnClientShowing
event. This is how you can do this:
in markup:
<cc1:CalendarExtender ID="toDate" runat="server" TargetControlID="txtDate" Format="MM/dd/yyyy" OnClientShowing="setDefaultDate" />
in javascript:
function setDefaultDate(sender,args)
{
if(sender._textbox.get_element().value == "")
{
var selectedDate = new Date(); //here i am using current date but you can get the selected date of From Calendar control and add +2 days
sender._selectedDate = selectedDate;
}
}
精彩评论