Welcome to Mediachase Community Sign in | Join | Help    
in Search   

Calendar control inside AJAX Update panel Issue

Last post Thu, Jul 24 2008, 4:36 AM by ga. 7 replies.
Sort Posts: Previous Next
  •  Mon, Jul 21 2008, 12:26 PM 9969

    Calendar control inside AJAX Update panel Issue

    I placed the AJAX calendar control inside a AJAX update panel so that only the Calendar gets updated when I click on Day, Week, Month or Task without the whole page being post back.

    But as soon as I placed the calendar inside update panel, nothing on the calendar control works. How can I achieve this since I don't want other contents on my page to be postback.

    Thanks
    Raj

     

  •  Tue, Jul 22 2008, 12:21 AM 9972 in reply to 9969

    Re: Calendar control inside AJAX Update panel Issue

    Hi,
    how did you place the control into update panel? The following code works fine:

    <asp:UpdatePanel runat="server" ID="up" >
    <ContentTemplate>
    <mc:MediachaseAjaxCalendar runat="server" ID="gCalendar"
    DrillDownEnabled="true">
    ...
    </mc:MediachaseAjaxCalendar>
    </ContentTemplate>
    </asp:UpdatePanel>

    What is your markup code with update panel and Ajax Calendar?

  •  Tue, Jul 22 2008, 9:43 AM 9975 in reply to 9972

    Re: Calendar control inside AJAX Update panel Issue

    First of all I'm working on the sample project I downloaded from this website. I Place the calendar control just like you did. But I also added Triggers for the Day, Week, Month, Year and Task Link buttons since they are outside the Calendar control.

    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
        <mc:MediaChaseAjaxCalendar runat="server" ID="gCalendar" DrillDownEnabled="true">
        ..............
        </mc:MediaChaseAjaxCalendar>
        </ContentTemplate>
         <Triggers>
                    <asp:AsyncPostBackTrigger ControlID="lbDay" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="lbWeek" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="lbMonth" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="lbYear" EventName="Click" />
                    <asp:AsyncPostBackTrigger ControlID="lbTask" EventName="Click" />
         </Triggers>
    </asp:UpdatePanel>


    It works only on click of any one link button. after that nothing works. Also the formatting for the link buttons do not change as well. Let me know if there is another way to do it.
    I'll keep trying untill then.
  •  Tue, Jul 22 2008, 9:51 AM 9976 in reply to 9972

    Re: Calendar control inside AJAX Update panel Issue

    I just tried the same with the trial edition - I wrapped the calendars in the demo app in an UpdatePanel like the following:

    <asp:UpdatePanel runat="server">
       
    <ContentTemplate>
          
    <div>
             
    <table border="0" cellpadding="0" cellspacing="0" style="width:100%;">
                
    <tr>
                   
    <td>
                      
    <a href="http://www.mediachase.com" style="border:0px;">
                         
    <img src="Images/MCCalendarLogo.jpg" style="border:0px;" />
                      
    </a> 
                   
    </td>
                   
    <td align="right">
                      
    <b>Calendar Skin Type:</b>
                      
    <asp:DropDownList runat="server" ID="ddSkinType" AutoPostBack="true">
                         
    <asp:ListItem Text="Google" Value="Google"></asp:ListItem>
                         
    <asp:ListItem Text="Outlook" Value="Outlook"></asp:ListItem>
                      
    </asp:DropDownList>
                  
    </td>
                
    </tr>
                
    <tr>
                   
    <td style="padding-top:10px;" colspan="2">
                      
    <mc:GCalendar runat="server" ID="gCalendar" /> 
                      
    <mc:OCalendar runat="server" ID="oCalendar" Visible="false" />
                   
    </td>
                
    </tr>
             
    </table>
          
    </div>
       
    </ContentTemplate>
    </
    asp:UpdatePanel>

    I get the following error message from Firebug when I switch to month view on the Google calendar:

    Sys.ScriptLoadFailedException: The script 'http://localhost:4858/ScriptResource.axd?d=blah' contains multiple calls to Sys.Application.notifyScriptLoaded(). Only one is allowed.

    Switching to week view is OK, but month, year and task fails.

    Is this a problem related to the trial or something else?

    Stein

  •  Wed, Jul 23 2008, 5:45 AM 9981 in reply to 9976

    Re: Calendar control inside AJAX Update panel Issue

    Hi everybody,

    error Sys.ScriptLoadFailedException occurs because script resource handler adds an instance of  Sys.Application.notifyScriptLoaded() call to the existing one in calendar java-script files. This issue is resolved and there will be no such error in next release. I think next release will be available soon.

    The question with update panel is more complicated. When you click link button and calendar view is changed (in update panel) you should re-register your custom handlers of calendar java-script events.
    You can use Sys.WebForms.PageRequestManager.getInstance().add_endRequest or Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded (in case of initial request HTTP GET or in case of page refresh) functions from Asp.Net Ajax client library for this purpose. Please see http://msdn.microsoft.com/ru-ru/library/bb398976(en-us).aspx for more information.

  •  Wed, Jul 23 2008, 11:13 AM 9983 in reply to 9981

    Re: Calendar control inside AJAX Update panel Issue

    Is there a temporary work-around for the notifyScriptLoaded() issue which makes it impossible to switch to month view when in an UpdatePanel? And when will it be fixed in the trial version?

    I'm creating a demonstration for a customer to show the potential with this control.

    Stein.

  •  Thu, Jul 24 2008, 1:15 AM 9986 in reply to 9983

    Re: Calendar control inside AJAX Update panel Issue

    Hi Stein,
    please see your e-mail box. I've sent to you variant of temporary work-around for the notifyScriptLoaded() issue.
  •  Thu, Jul 24 2008, 4:36 AM 9987 in reply to 9975

    Re: Calendar control inside AJAX Update panel Issue

    Hi Raj,
    we found one way of re-registering custom client event handlers of calendar events after update panel reloading. The initial solution was found at: http://weblogs.asp.net/infinitiesloop/archive/2007/09/17/inline-script-inside-an-asp-net-ajax-updatepanel.aspx

    For Outlook calendar skin you can do the following steps:
    1) Add the following code at the end of "OutlookCalendar.ascx.cs" file in WebSample calendar project
    namespace WebSample
    {
       
    public class InlineScript : Control
       {
          
    protected override void Render(HtmlTextWriter writer)
          {
             
    ScriptManager sm = ScriptManager.GetCurrent(Page);
             
    if (sm.IsInAsyncPostBack)
             {
                
    StringBuilder sb = new StringBuilder();
                
    base.Render(new HtmlTextWriter(new StringWriter(sb)));
                
    string script = sb.ToString();
                
    ScriptManager.RegisterStartupScript(this, typeof(InlineScript), UniqueID, script, false);
             }
             
    else
             
    {
                
    base.Render(writer);
             }
          }
       }
    }

    2) Place Outlook skinned calendar into ContentTemplate of update panel.
    3) Register WebSample namespace at the beginning of "OutlookCalendar.ascx" file:
    <%@ Register Assembly="WebSample" TagPrefix="ws" Namespace="WebSample" %>

    4) Place the following tag into ContentTemplate of update panel after calendar tag:
    <ws:InlineScript runat="server">
    </ws:InlineScript>

    5) Move all java-script from the end of  "OutlookCalendar.ascx" file into this tag.
    6) Add triggers to update panel:
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="lbDayView" EventName="Click" />
    <asp:AsyncPostBackTrigger ControlID="lbWeekView" EventName="Click" />
    <asp:AsyncPostBackTrigger ControlID="lbWorkWeekView" EventName="Click" />
    <asp:AsyncPostBackTrigger ControlID="lbMonthView" EventName="Click" />
    <asp:AsyncPostBackTrigger ControlID="lbYearView" EventName="Click" />
    <asp:AsyncPostBackTrigger ControlID="lbTaskView" EventName="Click" />
    </Triggers>

    Now in Outlook skinned calendar custom client event handlers are re-registered after update panel reloading. But you should care about highlighting link buttons with view names after calendar view is changed in update panel.

    When we used this way in "GoogleCalendar.ascx" file custom client event handlers were also re-registered successfully, but light pop-up editor (it is described in "GoogleEditor.js" file in web sample) did not behave correctly. So it needs to be modified for working with update panel.

    Hope this helps. 

View as RSS news feed in XML
Site Terms | Privacy Policy | About Us | Contact Us
Running on Mediachase eCommerce Framework 4.0.
  Copyright © Mediachase, LTD. 1997-2006. All Rights Reserved

E-commerce, HelpDesk, Service Desk & Project Management Software, alternatives to Microsoft Project Server & Sharepoint Collaboration Server
project management software | microsoft project server | sharepoint collaboration server | issues management, helpdesk & service desk
Powered by Community Server, by Telligent Systems