1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Update Panel Issue

Update Panel Issue

3 posts, 0 answered
  1. Bryan
    Bryan avatar
    14 posts
    Registered:
    20 Aug 2008
    03 Mar 2009
    Link to this post
    Hi,
    I am using UpdatePanel within the user control, which is placed on the master template. I do not have any problems with live site. But when I add / remove controls to / from my pages using Sitefinity CMS I get error message:

    Cannot unregister UpdatePanel with ID 'pnlUpdt' 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

    Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

    Exception Details: System.ArgumentException: Cannot unregister UpdatePanel with ID 'pnlUpdt' 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




    Then, when I click Back button in the browser, I see that control was successfully added / removed.
    Could you please advise the solution to avoid getting this error message?

    Thanks.

    Bryan.
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    16 Jun 2017
    04 Mar 2009
    Link to this post
    Hi Bryan,

    Please take a look at the following KB article Cannot unregister UpdatePanel with ID. Generally you could try removing RadAjaxPanel from the control template and then add the control OnPreInit and and RadAjaxPanel control to a placeholder. Then, get the number of controls and finally clear the controls from the placeholder in ajax Panel.

    Sample:

    protected override void OnInit(EventArgs e)  
        {  
            // we have added place holder instead of control declaration   
            if (!IsPageInAdmin())  
            {  
                // add RadAjaxPanel control.  
                RadAjaxPanel ajaxPanel = new RadAjaxPanel();  
                ajaxPanel.Width = Unit.Percentage(100);  
                Control ctrl = plh.Controls[0];  
                while (ctrl != null)  
                {    
                    // get number of controls  
                    ajaxPanel.Controls.Add(ctrl);  
                    if (plh.Controls.Count == 0)  
                        break;  
                    ctrl = plh.Controls[0];  
                }  
                // clear the controls form the placeholder and ajaxPanel.  
                plh.Controls.Clear();  
                plh.Controls.Add(ajaxPanel);  
            }  
            base.OnInit(e);  
        }  

    I hope this helps.

    All the best,
    Ivan Dimitrov
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Bryan
    Bryan avatar
    14 posts
    Registered:
    20 Aug 2008
    04 Mar 2009
    Link to this post
    Hi Ivan,

    Thanks for the response. I've tried my own solution which helped me. The UpdatePanel in my user control caused the problem. So, I added the following code that solved it.

    Protected

    Overloads Overrides Sub OnInit(ByVal e As EventArgs)

    MyBase.OnInit(e)

    AddHandler Me.pnlUpdt.Unload, AddressOf UpdatePanel_Unload

    End Sub

     

    Private Sub UpdatePanel_Unload(ByVal sender As Object, ByVal e As EventArgs)

    Me.RegisterUpdatePanel(TryCast(sender, UpdatePanel))

    End Sub

     

    Public Sub RegisterUpdatePanel(ByVal upnl As UpdatePanel)

    Dim arrObj() As Object = {upnl}

    For Each methInfo As MethodInfo In GetType(ScriptManager).GetMethods(BindingFlags.NonPublic Or BindingFlags.Instance)

    If methInfo.Name.Equals("System.Web.UI.IScriptManagerInternal.RegisterUpdatePanel") Then

     

    methInfo.Invoke(ScriptManager.GetCurrent(Page), arrObj)

    End If

     

    Next

     

    End Sub

     

Register for webinar
3 posts, 0 answered