This is a migrated thread and some comments may be shown as answers.

RadCalendar causing Postbacks

1 Answer 51 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
Kent
Top achievements
Rank 1
Kent asked on 26 Feb 2012, 03:51 AM
I have two RadCalendars inside a <div>. I want to be able to hide/show this div with jQuery, however anytime the <div> is shown/hidden the controls are causing a postback, which resets the state of the calendars. This even though the AutoPostBack property is set to "false" (both in the .aspx attribute, and Page_Load of code-behind. WHY? And how can I stop this behavior?

<div id="calendars" style="width: 450px" >
    <div style="float: left">
        <telerik:RadCalendar ID="dpStart" runat="server" AutoPostBack="false"
                                             UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" EnableMultiSelect="False"
                                             ShowFastNavigationButtons="False" ShowRowHeaders="False"
                                             RangeMaxDate="2050-12-31" RangeMinDate="2008-01-01" FocusedDate="2008-01-01"
                                             SelectedDate="" Skin="Metro" ViewSelectorText="x" >
                            <ClientEvents OnDateSelected="dpStart_OnDateSelected" OnCalendarViewChanging="OnCalendarViewChanging" />
                        </telerik:RadCalendar>
                    </div>
 
                    <div style="float: right">
                        <telerik:RadCalendar ID="dpEnd" runat="server" AutoPostBack="false"
                                             UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" EnableMultiSelect="False"
                                             ShowFastNavigationButtons="False" ShowRowHeaders="False"
                                             RangeMaxDate="2050-12-31" RangeMinDate="2008-01-01" FocusedDate="2008-01-01"
                                             SelectedDate="" Skin="Metro" ViewSelectorText="x" >
                            <ClientEvents OnDateSelected="dpStart_OnDateSelected" OnCalendarViewChanging="OnCalendarViewChanging" />
                        </telerik:RadCalendar>
     </div>
</div>
 
 <button id="button">Toggle</button>
 
<script type="text/javascript">
    $("#button").click(function() {
        $("#calendars").toggle();
     });
</script>

1 Answer, 1 is accepted

Sort by
0
Vasil
Telerik team
answered on 27 Feb 2012, 05:38 PM
Hi Kent,

The problem is not in the calendar itself.
Actually the button makes Postback, because it's click event is never canceled.

Try your code like:
    <script type="text/javascript">
      $("#button").click(function ()
      {
        $("#calendars").toggle(); return false;
      });
</script>

All the best,
Vasil
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Calendar
Asked by
Kent
Top achievements
Rank 1
Answers by
Vasil
Telerik team
Share this question
or