Calling Calendar Postback event

4 posts, 1 answers
  1. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 18 Mar 2010 Link to this post

    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?
  2. Tsvetoslav
    Admin
    Tsvetoslav avatar
    1823 posts

    Posted 22 Mar 2010 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. robertw102
    robertw102 avatar
    265 posts
    Member since:
    Jul 2007

    Posted 22 Mar 2010 Link to this post

    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.
  5. Answer
    Nikolay Rusev
    Admin
    Nikolay Rusev avatar
    2285 posts

    Posted 25 Mar 2010 Link to this post

    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.
Back to Top