UpdatePanel in ContentTemplate - Unregister error

9 posts, 0 answers
  1. Jonathan
    Jonathan avatar
    12 posts
    Member since:
    Aug 2015

    Posted 05 Apr Link to this post

    I am dynamically generating a RadWindow with an AJAX UpdatePanel added to it's ContentTemplate in my custom server control (during the control's Init event) like so:

    _updatePanel = new UpdatePanel() { ID = string.Format("{0}_UpdatePanel", ID), UpdateMode = UpdatePanelUpdateMode.Conditional };
    _modalWindow = new RadWindow();
    _modalWindow.ID = string.Format("{0}_radWindow", ID);
    _modalWindow.ContentContainer.Controls.Add(_updatePanel);

    The server control with said RadWindow is also dynamically declared in a RadGrid's GridTemplateColumn. The idea is when the user edits a RadGrid record that contains a RadComboBox the user can view/edit the details of the selected RadComboBox item in a RadWindow popup. This all works fine until I attempt to hit the Save or Cancel button on the RadGrid to close edit mode.

    I am aware of the following posts that describe why the error is happening but I am not sure how to go about solving this in my situation.

    http://www.telerik.com/support/kb/aspnet-ajax/window/details/cannot-unregister-updatepanel-with-id-updatepanelid-since-it-was-not-registered-with-the-scriptmanager-error

    http://www.telerik.com/forums/is-a-partial-postback-with-radwindow-possible

    It seems the solution is to declare the RadWindow directly on the page. The problem is I am developing a server control, would it work if I got a reference to the Page and added it directly instead of to the ControlCollection of my server control?

     

    Thanks!

     

  2. Jonathan
    Jonathan avatar
    12 posts
    Member since:
    Aug 2015

    Posted 06 Apr in reply to Jonathan Link to this post

    To be clear, the error I am receiving is as follows:

    Cannot unregister UpdatePanel with ID 'UpdatePanelID' since it was not registered with the ScriptManager.

    I know the reason for this is that the UpdatePanel has been moved from it's location inside my custom control to the first child of the Form on the page. I guess then this messes up the ScriptManager because it is trying to unregister a control that it cannot find?

    Also, some information that may be helpful. I am not using the VisibleOnPageLoad property to show the RadWindow. I am using ScriptManager.RegisterStartupScript to find and show the RadWindow. 

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 07 Apr Link to this post

    Hello Jonathan,

    I cannot guarantee you that adding the RadWindow instance to the page directly would be a solution. Also, it will be out of the UpdatePanel. And if this is so, why the UpdatePanel should be involved with RadWindow in the first place.

    Why not using RadAjaxManager instead of UpdatePanel?

    Regards,
    Ianko
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  5. Jonathan
    Jonathan avatar
    12 posts
    Member since:
    Aug 2015

    Posted 08 Apr in reply to Ianko Link to this post

    I'm using an UpdatePanel because the content in the RadWindow will post back to the server and I do not want the window to flash or the page to reload. I am not sure how I would use a RadAjaxManager in my scenario.

    Also, it seems that adding the UpdatePanel to the page did work except I cannot actually show the modal now because of the way I was opening it, like so:

    string script = "function showModal() { $find(\"" + _modalWindow.ClientID + "\").show(); Sys.Application.remove_load(showModal); } Sys.Application.add_load(showModal);";
    ScriptManager.RegisterStartupScript(Page, Page.GetType(), string.Format("{0}_ShowModal", ID), script, true);

    The error I get is, could not find 'ModalWindowID'.

  6. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 11 Apr Link to this post

    Hello Jonathan,

    Using RadAjaxManager is documented here—http://docs.telerik.com/devtools/aspnet-ajax/controls/ajaxmanager/overview. You can still use it programmatically. Where you can check if there is am AjaxManager on the page and just configure it further as per to you needs. Or you can use RadAajxManagerProxy if you have already declared a RadAjaxManager in the application. 

    As for RadWindow modal behavior, the described situation is expected. With AJAX-enabled control, RadWindow cannot render its modal div element that is typically added at the end of the form. Where AJAX techniques cannot  enable adding DOM elements outside the UpdatePanel.

    In this case, I suggest you rendering RadWindow without modal behavior and enabling it on the client by using the set_modal(true) method.
     
    Regards,
    Ianko
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  7. Jonathan
    Jonathan avatar
    12 posts
    Member since:
    Aug 2015

    Posted 11 Apr in reply to Ianko Link to this post

    I just removed the modal behavior of the RadWindow by settings the Modal property to false (_modalWindow.Modal = false) on my server control and I am still experiencing the same issue. I also have EnableViewState = true - not sure if this makes a difference? I need the viewstate functionality though because the post backs on the control need to remember the values the user has entered.

    I will attempt to use the RadAjaxManager next and report back. I appreciate your help.

  8. Ianko
    Admin
    Ianko avatar
    1535 posts

    Posted 14 Apr Link to this post

    Hello Jonathan,

    I do not see how ViewState could be relevant to the case with the JS error.

    Also, if the error is still the same when loading non-modal RadWindow, can you please provide a markup example of the issue so that I can properly understand the scenario?

    Regards,
    Ianko
    Telerik
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  9. Jonathan
    Jonathan avatar
    12 posts
    Member since:
    Aug 2015

    Posted 03 May in reply to Ianko Link to this post

    So the only way I could fix this issue is by forcefully registering the UpdatePanel with the ScriptManager every time the UpdatePanel is unloaded. This seems like an unconventional fix and I am worried what repercussions this may have.

    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 });}

  10. Jonathan
    Jonathan avatar
    12 posts
    Member since:
    Aug 2015

    Posted 03 May in reply to Jonathan Link to this post

    that fix was discovered in this post http://stackoverflow.com/questions/8727658/cannot-unregister-updatepanel-with-id-xxx-since-it-was-not-registered-with-th
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017