CMS:Calendar Control and Update Panel

asked on January 14, 2016 08:39

Hello. I am using CMS:Calendar control on my website and when you change months page is refreshing. I used update panel to prevent refreshing the page but it doesn't work. Can you help me please and write instruction how to use update panel with kentico cms controls. I'm posting code that I have below:

<%@ Control Language="C#" AutoEventWireup="true" Inherits="CMSWebParts_Viewers_Documents_cmscalendar" CodeFile="~/CMSWebParts/Viewers/Documents/cmscalendar.ascx.cs" %> <asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional"> </asp:UpdatePanel>

Thanks in advance

Recent Answers


Dawid Jachnik answered on January 14, 2016 09:23 (last edited on January 14, 2016 09:23)

Hello,

Did you tried to remove your UpdatePanel and on the web part properites mark the Use update panel on AJAX tab?

Image Text

1 votesVote for this answer Mark as a Correct answer

answered on January 14, 2016 09:28 (last edited on December 6, 2018 08:31)

Thank you for your fast response. Yes I did but still not working. Then I opened CMSWebParts\Viewers\Documents\ CMSCalendar.ascx and modified code there. Updated code is:

cmscalendar.ascx:

<asp:UpdatePanel ID="upReportsList" runat="server" UpdateMode="Conditional" OnUnload="UpdatePanel_Unload" ChildrenAsTriggers="true"> </asp:UpdatePanel>

and event for update panel unload.

cmscalendar.ascx.cs:

protected void UpdatePanel_Unload(object sender, EventArgs e) { MethodInfo methodInfo = typeof(ScriptManager).GetMethods(BindingFlags.NonPublic | BindingFlags.Instance).Where(i => i.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel")).First(); methodInfo.Invoke(ScriptManager.GetCurrent(Page), new object[] { sender as UpdatePanel }); }

It's working but I guess it's not convenient way to do that, because when I modify kentico built-in controls I feel like, I am wrong. please tell me what is better way to do that.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 14, 2016 14:21

@George I highly recommend changing whatever code you modified back to the original simply for upgrade reasons. Best practice and Kentico recommendataions state to clone the controls and then modify the code.

To answer your question, after you have reverted your changes, place the webpart on your page template and in the properties of the webpart there is an AJAX section, expand it and check the box to use an update panel. This will place an update panel around the webpart. If you need other things to update based on the selections in that webpart then go to the web part zone which has all your web parts in it and check that box to use an update panel.

0 votesVote for this answer Mark as a Correct answer

answered on January 14, 2016 14:30 (last edited on December 6, 2018 08:31)

I restored original state of control and followed instructions you gave me. Place calendar control to webpart zone, then went to calendar properties and check use update panel checkbox, but I've got a error. Cannot unregister UpdatePanel with ID 'UpdatePanel1' since it was not registered with the ScriptManager. This might occur if the UpdatePanel was removed from the control tree and later added again, which is not supported. Parameter name: updatePanel

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on January 14, 2016 21:39

@George, the error might be because you still have an update panel in your code. Double check you've removed it in your code or reverted the OOTB control back to original settings and try again. Could also be caching the file too in which case, restarting your website should resolve this.

0 votesVote for this answer Mark as a Correct answer

answered on January 15, 2016 06:47 (last edited on December 6, 2018 08:31)

Brenden, I have this code in my webpart layout <cms:CMSCalendar ID="calItems" runat="server" DayField="DocumentModifiedWhen" /> and I checked Use update Panel checkbox in AJAX tab. But When I change months it still refreshes whole page. Also when i see rendered html in inspect element there is no appended update panel markup.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.