开发者

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;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜