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

Calling Calendar Postback event

3 Answers 111 Views
Calendar
This is a migrated thread and some comments may be shown as answers.
robertw102
Top achievements
Rank 1
robertw102 asked on 18 Mar 2010, 05:16 PM
I have a calendar control, which can be viewed in the two available modes, Interactive or Preview, depending on what's needed. By default, I have my Calendar control set to AutoPostback="true", so that I can handle the calendar navigation event. The problem I get is that when I have the control in Interactive mode, since I want the user to select the dates, it will always postback because of the AutoPostback setting. So what I want to do is that when I have the control in Interactive mode I would set AutoPostback="false", to prevent post backs when a date is selected and only postback when they navigate the calendar.

How would I be able to cause the postback for the navigation event?

3 Answers, 1 is accepted

Sort by
0
Tsvetoslav
Telerik team
answered on 22 Mar 2010, 04:46 PM
Hi Robert,

Here is the code for achieving this:

<telerik:RadScriptBlock ID="ScriptBlock1" runat="server">
    <script type="text/javascript">
          
          
        function viewChanged(sender, args)
        {         
            __doPostBack('RadCalendar','n:' + args.get_step())
        }
          
    </script>
</telerik:RadScriptBlock>
<telerik:RadCalendar ID="RadCalendar1" runat="server" AutoPostBack="false" >
    <ClientEvents OnCalendarViewChanged="viewChanged" />
</telerik:RadCalendar>

I hope it helps.

Regards,
Tsvetoslav
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
robertw102
Top achievements
Rank 1
answered on 22 Mar 2010, 08:29 PM
Hello Tsvetoslav,

The postback does occur, but it doesn't raise the OnDefaultViewChanged event of the RadCalendar control. Is the solution you provided me supposed to raise that event or am I supposed to be handling the RaisePostBackEvent and then call the OnDefaultViewChanged event.

In my previous post I was asking if I could raise the OnDefaultViewChanged event with AutoPostback="false", not just create a normal postback and handle it in the RaisePostBackEvent. Or is that the only way I can accomplish something like this?

Thanks.
0
Accepted
Nikolay Rusev
Telerik team
answered on 25 Mar 2010, 12:14 PM
Hello Robert,

It should be "RadCalendar1" instead "RadCalendar" in __doPostBack call. The following snippet is event better:
1.<telerik:RadScriptBlock ID="ScriptBlock1" runat="server"
2.    <script type="text/javascript">
3.        function viewChanged(sender, args)
4.        {
5.            __doPostBack('<%=RadCalendar1.UniqueID %>', 'n:' + args.get_step())
6.        }           
7.    </script> 
8.</telerik:RadScriptBlock>

DefaultViewChanged event will be triggered.

Regards,
Nikolay
the Telerik team


Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
Tags
Calendar
Asked by
robertw102
Top achievements
Rank 1
Answers by
Tsvetoslav
Telerik team
robertw102
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or