【问题标题】:selecting particular month as default in calendar extender在日历扩展器中选择特定月份作为默认月份
【发布时间】:2012-03-22 19:47:41
【问题描述】:

我有一个开始日期和结束日期字段。两者都有单独的 ajax 日历扩展器。一旦我们在选择开始日期后单击结束日期日历控件,我想在结束日期日历中显示与开始日期对应的同一月份。我们怎么能这样做。我尝试在日历扩展器的客户端显示事件上添加javascript函数;但没有成功。

基本思想是用户可以通过任何方式在 endate 文本框中选择大于开始日期的日期。

【问题讨论】:

  • 您使用的是什么日历?您可以发布您的代码示例以及您尝试做的事情吗?

标签: asp.net ajax


【解决方案1】:

刚刚使用了一个 js 调试器来查看 CalendarExtender 在客户端有哪些属性和功能。发现了两个有趣的东西,OnClientShown 事件和set_visibleDate 函数:

<script type="text/javascript">
    function ApplyStartMonth(sender, args) {
        var calendarStart = $find('CalendarExtender1');
        sender.set_visibleDate(calendarStart._selectedDate);
        // the following is not needed here but good to know that they exist
        //sender.set_todaysDate(calendarStart._selectedDate);
        //sender.set_selectedDate(calendarStart._selectedDate);
    }
</script>

<asp:TextBox ID="TxtStart" runat="server" Text="22.03.2012"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender1" runat="server" Format="dd.MM.yyyy" TargetControlID="TxtStart" /><br />
<asp:TextBox ID="TxtEnd" runat="server"></asp:TextBox>
<cc1:CalendarExtender ID="CalendarExtender2" runat="server" Format="dd.MM.yyyy" 
   OnClientShown="ApplyStartMonth" TargetControlID="TxtEnd" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-07-19
    相关资源
    最近更新 更多