Error using ScriptManager, UpdatePanel and Beta 1

Last post 07-27-2007 4:58 PM by Peron17. 19 replies.

Sort Posts:

  • Error using ScriptManager, UpdatePanel and Beta 1

    10-25-2006, 2:27 PM
    • Loading...
    • brianedow
    • Joined on 02-03-2006, 1:50 PM
    • Posts 12

    As one else see this error:

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

    There is something different from July CTP and Beta 1 with scriptmanager.  Can any one help?

     

     

  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-25-2006, 6:16 PM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,218

    hello,

    not without seeing the code (just a small demo would be fine) or understanding what you're trying to do...

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-26-2006, 3:15 AM
    • Loading...
    • seano288
    • Joined on 07-11-2003, 6:53 PM
    • Posts 44

    I'm also experiencing this error.  I've made no code changes but only upgraded to Beta 1.  This is occurring in a user control for me:

     

    <div class="subheader sectionsubheader">
        <asp:Label ID="Label1" runat="server" Text="Addresses"></asp:Label></div>
    <div class="subsection">    
        <ajax:UpdatePanel ID="updatePanel1" runat="server" UpdateMode="conditional">
            <ContentTemplate>
                <asp:PlaceHolder ID="plcAddresses" runat="server"></asp:PlaceHolder>
            </ContentTemplate>
            <Triggers>
                <ajax:AsyncPostbackTrigger ControlID="lnkAddAddress" EventName="Click" />
            </Triggers>
        </ajax:UpdatePanel>
        <div style="margin-top: 20px; border-top: 1px solid gainsboro; padding: 6px;">
            <asp:LinkButton ID="lnkAddAddress" runat="server" Text="Add address" OnClick="AddAddress" /></div>
    </div>
     The UpdatePanel in this aspx causes the error.  This user control does not have a script manager, but the parent page does.  Putting in a proxy makes no difference.  
    updatePanel1 is not referenced in any code behind. Here is my server 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
     
     
      
    Sean Campbell
    Software Engineer
    http://www.danswine.com
  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-26-2006, 3:30 AM
    • Loading...
    • gururajmk
    • Joined on 10-26-2006, 7:20 AM
    • Posts 2

    hi,

     I am sorry , i dont know the answer for this. But i replied u since i wanted to know hw to post the questions. i am not finding any link to post. Can u help me out in that. Once again sorry. and if u knw how to use splitter in Atlas please let me know

     

  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-26-2006, 8:32 AM
    • Loading...
    • brianedow
    • Joined on 02-03-2006, 1:50 PM
    • Posts 12

    I will try to provide an example today. In the meantime, I will try to describe the issue we are having in words.  Currently, our web project aspx pages inherit from a base page, like a master page.  This base page/class inherits from Web.UI.Page.  The reason why we did this was for a number of reasons, but mostly to centralize utility functions, session management, and to emulate the concept of a master page, before there was the idea of master pages.  The basic function of the base page is to load the child pages controls into the base page’s form object.   It seems that this operation of removing the control from the child control to the parent page’s form object, the base page, causes this error.  This error did not happen in the any of the CTP releases.  Today, we are planning on looking into the possibility of using master pages, and I hope we can still use our base page for the rest of our needs.   I really do not understand why Atlas/Ajax team would add this error.  I’m glad to see that others are having this problem, which makes me feel a little bit better and also a little bitter.  Why would they completely change an almost stable framework?  I hope that we can solve this issue quickly and/or communicate this bug to the Atlas/Ajax team so they could help us solve this error.  Again, I will post a sample later in the day, once we have confirmed our hypothesis and simplified our base page code for public consumption.

  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-26-2006, 8:47 AM
    • Loading...
    • brianedow
    • Joined on 02-03-2006, 1:50 PM
    • Posts 12

    I also want to share the whole call stack with you:

     [ArgumentException: Cannot unregister UpdatePanel with ID 'upData' 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]
       Microsoft.Web.UI.PageRequestManager.UnregisterUpdatePanel(UpdatePanel updatePanel) +216
       Microsoft.Web.UI.ScriptManager.Microsoft.Web.UI.IScriptManagerInternal.UnregisterUpdatePanel(UpdatePanel updatePanel) +67
       Microsoft.Web.UI.UpdatePanel.OnUnload(EventArgs e) +71
       System.Web.UI.Control.UnloadRecursive(Boolean dispose) +267
       System.Web.UI.Control.UnloadRecursive(Boolean dispose) +204
       System.Web.UI.Control.UnloadRecursive(Boolean dispose) +204
       System.Web.UI.Page.UnloadRecursive(Boolean dispose) +20
       System.Web.UI.Page.ProcessRequestCleanup() +40
       System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154
       System.Web.UI.Page.ProcessRequest() +86
       System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
       System.Web.UI.Page.ProcessRequest(HttpContext context) +49
       ASP.myPage_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\TestingBeta_1_Ajax\4f4d9c3a\1556dfbd\App_Web_iq5hndmf.26.cs:0
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-26-2006, 11:27 AM
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,218

    hello guys.

    i can see where the error is happening...just can't seem to repreoduce it. it looks like you're loading the control dynamically, right. if so, can you tell me when you're loading it. i've tried running this sample and it worked ok here:

     
    page aspx 

    <%@ Page Language="C#" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <script runat="server">
        protected override void OnLoad(EventArgs e)
        {  
            base.OnLoad( e );

            holder.Controls.Add( this.LoadControl("webusercontrol.ascx") );
            holder.Controls.Clear();
        }
    </script>

    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>Untitled Page</title>
    </head>
    <body>
        <form id="form1" runat="server">
            <asp:ScriptManager runat="server" ID="Manager" />
            <asp:PlaceHolder runat="server" ID="holder">
            </asp:PlaceHolder>
        </form>
    </body>
    </html>

    user control:

     <%@ Control Language="VB" ClassName="WebUserControl" %>

    <script runat="server">

    </script>
    <asp:UpdatePanel runat="server" ID="panel">
        <ContentTemplate>
            <%= DateTime.Now.ToString() %>
            <asp:Button runat="server" ID="bt" Text=" refresh" />
        </ContentTemplate>
    </asp:UpdatePanel>

    if you can give more info on how i could change my code to get that error, i might be able to help you.

    thanks. 

     

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-26-2006, 10:14 PM
    • Loading...
    • seano288
    • Joined on 07-11-2003, 6:53 PM
    • Posts 44

    The user control code that I posted above (ucEditPartner below) appears in another page which doesn't load it dynamically ... it is however set to visible='false' when initially loaded:

     

    <asp:PlaceHolder ID="plcEditPartner" runat="server" Visible="false">
        <div class="sectionheader detailslabel">
             <asp:Panel ID="PanelActionEdit" runat="server">
                  <asp:HyperLink ID="lnkReturnFromEdit" runat="server" Text="Return to contacts" NavigateUrl="javascript: ShowContact(-1)" />
             </asp:Panel>
        </div>
        <uc:EditPartner ID="ucEditPartner" runat="server" />
    </asp:PlaceHolder>
     This place holder has its visiblity set by javascript depending on user action. 
     Hope this helps. 
     
    Sean Campbell
    Software Engineer
    http://www.danswine.com
  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-26-2006, 10:31 PM
    • Loading...
    • seano288
    • Joined on 07-11-2003, 6:53 PM
    • Posts 44

    I ran a test and set the place holder to visible='true' but I'm still getting the same error.  The placeholder above is embedded in a ComponentArt callback control.

    brianedow, do you happen to be using ComponentArt controls too? 

    Sean Campbell
    Software Engineer
    http://www.danswine.com
  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-27-2006, 4:07 AM
    Answer
    • Loading...
    • Luis Abreu
    • Joined on 02-12-2005, 6:22 AM
    • Madeira [Portugal]
    • Posts 5,218

    hi.

    in Brian's case, he sent me the code and i was able to take a peek at it. the problem here is that you can't add/remove/add an updatepanel duing the page life cicle since that will break it (you can only add/remove/add again until the end of the preinit event if you want to get everything working....

    --
    Regards,
    Luis Abreu
    email: labreu_at_gmail.com
    PT blog: http://weblogs.pontonetpt.com/luisabreu
    EN blog:http://msmvps.com/blogs/luisabreu
    http://www.pontonetpt.com
    http://weblogs.pontonetpt.com/
  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-27-2006, 8:12 AM
    • Loading...
    • brianedow
    • Joined on 02-03-2006, 1:50 PM
    • Posts 12

    Thanks to Luis, we have discovered when removing or removing and adding controls back to the page must be done in the OnPreInit.  DO NOT USE event OnInit when using Beta 1.

     
     
    1    using System;
    2    using System.Web.UI;
    3    using System.Web.UI.HtmlControls;
    4    
    5    /// <summary>
    6    /// Summary description for AjaxTestBase
    7    /// </summary>
    8    public class AjaxTestBase : Page
    9    {
    10       protected myForm m_Form = null;
    11   
    12   	public AjaxTestBase()
    13   	{
    14   		//
    15   		// TODO: Add constructor logic here
    16   		//
    17   	}
    18   
    19       protected virtual HtmlForm GenerateHtmlForm()
    20       {
    21           m_Form = new myForm();
    22           AddControlsFromDerivedPage(m_Form);
    23           return m_Form;
    24       }
    25       /// <summary>
    26       /// In order to make the base page to work, we need to collect all the 
    27       /// elements from the child page and make them basepage's form elements 
    28       /// </summary>
    29       /// <param name="form"></param>
    30       protected virtual void AddControlsFromDerivedPage(HtmlForm form)
    31       {
    32           int count = this.Controls.Count;
    33           for (int i = 0; i < count; ++i)
    34           {
    35               //We will always read the first one in the list, 
    36               //since we remove the first one each time we loop through the list.
    37               //Therefore, that is why we read index zero always
    38   
    39               Control ctrl = this.Controls[0];
    40               form.Controls.Add(ctrl);
    41               this.Controls.Remove(ctrl);
    42           }
    43       }
    44   
    45       private void BuildBasePage(HtmlForm form)
    46       {
    47           ////////////////////////////////////////////////////////
    48           // Build the page and include the generated form
    49           ////////////////////////////////////////////////////////
    50   
    51   
    52           //Creating the Top of the base Page
    53           this.Controls.AddAt(0, new LiteralControl(@"&lt;!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.01 Transitional//EN"" ""http://www.w3.org/TR/html4/loose.dtd"">
    54   				<html>
    55   				<head>
    56   					<title>" + "AjaxTest" + @"&lt;/title>
    57   				</head>
    58   				<body>
    59   		"));
    60           
    61           
    62           this.Controls.Add(form);
    63           this.Controls.Add(new LiteralControl(@"
    64   		</body>
    65   		</html>
    66   											"));
    67       }
    68   
    69       /// <summary>
    70       /// Raises the <see cref="E:System.Web.UI.Page.PreInit"></see> event at the beginning of page initialization.
    71       /// When using Ajax (aka Atlas) control must be removed and added back before anyone else does.  
    72       /// </summary>
    73       /// <param name="e">An <see cref="T:System.EventArgs"></see> that contains the event data.</param>
    74       protected override void OnPreInit(EventArgs e)
    75       {
    76           BuildBasePage(GenerateHtmlForm());
    77           base.OnPreInit(e);
    78       }
    79   
    80       /// <summary>
    81       /// 
    82       /// </summary>
    83       public class myForm : HtmlForm
    84       {
    85           /// <summary>
    86           /// 
    87           /// </summary>
    88           public myForm()
    89           {
    90               base.Method = "Post";
    91               base.Enctype = "multipart/form-data";
    92           }
    93       }
    94   }
    95   
    
      
         

     

  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-27-2006, 8:16 AM
    • Loading...
    • brianedow
    • Joined on 02-03-2006, 1:50 PM
    • Posts 12

    I am sorry to say that we are not using any third party controls.  We are using either Web.UI.Control directly or custom controls developed in house. 

  • Re: Error using ScriptManager, UpdatePanel and Beta 1

    10-31-2006, 4:14 AM
    • Loading...
    • Red Eagle
    • Joined on 10-18-2006, 2:59 PM
    • Posts 7

    Hello @ all,

    I have the same error ("Cannot unregister UpdatePanel with.....") but I'm not able to use your solution.
    My problem is that i'm only using one page event at the the user control where the error occurs (Page_Load event for adding an event handler).

    I cannot use the pre_init event because a user control don't have it.
     

    can someone give me a hint? 

    Masterpage: 

    1    ... 
    2 3 <form id="form1" runat="server">
    4 <asp:ScriptManager ID="scriptManager" runat="server" />
    5 6 ...
    7 8 <div id="content">
    9 <asp:ContentPlaceHolder ID="placeHolder_content" runat="server">
    10 </asp:ContentPlaceHolder>
    11 </div>
    12 13 ...
     

    aspx Page:

    1    <%@ Register src="~/aspx/test.ascx" TagPrefix="test" tagname="testcontrol" %>
    2    
    3    ...
    4 5 <test:testcontrol ID="myTestControl" runat="server" />
    6 7 ...
     

    user control:

    1    ... 
    2 3 <asp:UpdatePanel ID="upd_pnl" runat="server" RenderMode="Block">
    4 <ContentTemplate>
    5 <asp:DropDownList ID="cmb_test" runat="server" AutoPostBack="true">
    6 <asp:ListItem>test1</asp:ListItem>
    7 <asp:ListItem>test2</asp:ListItem>
    8 <asp:ListItem>test2</asp:ListItem>
    9 </asp:DropDownList>
    10 </ContentTemplate>
    11 </asp:UpdatePanel>
    12 ...
      In the code behind class of the user control i only have registered the event SelectedIndexChanged manualy (in the page_load event)