Custom Controls, DLLs, ScriptManager and Update Panels

Last post 07-31-2008 8:53 PM by silverjoe. 4 replies.

Sort Posts:

  • Custom Controls, DLLs, ScriptManager and Update Panels

    12-27-2006, 6:03 PM
    • Loading...
    • takobell
    • Joined on 07-07-2006, 10:09 PM
    • Posts 8

    Having some issues getting an UpdatePanel to work inside a custom control in a master page scenario.  I have a hunch it has something to do with page life cycles, but just can't seem to figure it out.  Here is the relevant code sections:

    StandardLayout.Master

    1    <body>
    2        <form id="form1" runat="server">
    3            <asp:ScriptManager id="scriptManager" runat="server" EnablePartialRendering="true" />
    4    
    5            <div runat="server" id="content">
    6                <asp:ContentPlaceHolder runat="server" ID="MainContent"></asp:ContentPlaceHolder>
    7            </div>
    8       </form>
    9    </body>
     
    Products.aspx 
    1    <%@ Page MasterPageFile="~/StandardLayout.master" Language="C#" CodeFile="Products.aspx.cs" Inherits="Products" %> 
    2    
    3    <asp:Content ID="MainContent" ContentPlaceHolderID="MainContent" runat="Server" >
    4    
    5        <asp:Panel runat="server" ID="ProductDisplayPanel" ScrollBars="None">
    6            <cc1:ProductDetail runat="server" ID="ProductDetail" CssClass="ProductDetail" />
    7        </asp:Panel>
    8    
    9    </Content>
    

     

    The ProductDetail custom control is a compiled .DLL file.

    The relevant code for it is:

    ProductDetail.cs 

    1    public class ProductDetail : CompositeControl, INamingContainer
    2    {
    3        private UpdatePanel AjaxUpdatePanel = new UpdatePanel();
    4        private Table table = new Table();
    5    
    6        protected override void OnInit(EventArgs e)
    7        {
    8    
    9            AjaxUpdatePanel.ID = "productUpdatePanel";
    10          AjaxUpdatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional;
    11   
    12           base.OnInit(e);
    13       }
    14   
    15       protected override void CreateChildControls()
    16       {
    17           // build fancy table content here
    18   
    19           AjaxUpdatePanel.ContentTemplateContainer.Controls.Add(table);
    20           this.Controls.Add(AjaxUpdatePanel);
    21       }
    22   } 
    
     

    The error I get is at Line 20 in ProductDetail.cs and it says something to the effect of "the control with ID 'productUpdatePanel' requires a ScriptManager.  can't find scriptmanager, make sure it's added before you use this control, etc."

     Of course the ScriptManager is way back up in the StandardLayout.Master file.

     Any ideas or suggestions?

     
    Thanks,

    Brad

     



     

  • Re: Custom Controls, DLLs, ScriptManager and Update Panels

    12-27-2006, 8:41 PM
    • Loading...
    • MIB426
    • Joined on 04-25-2003, 3:19 AM
    • Taiwan or Australia
    • Posts 842

    with master page case, you need to use ScriptManagerProxy

     

    hope this help

    James Wu (MIB426)
    .NET is only way to go
    MCP, MCSE, MCDBA, MCSD, MCAD
  • Re: Custom Controls, DLLs, ScriptManager and Update Panels

    12-28-2006, 1:14 PM
    • Loading...
    • takobell
    • Joined on 07-07-2006, 10:09 PM
    • Posts 8

    I added a ScriptManagerProxy to Products.aspx and I still get this error in ProductDetail.cs on the same line:

    The control with ID 'productUpdatePanel' requires a ScriptManager on the page. The ScriptManager must appear before any controls that need it.

    I even tried adding ScriptManagerProxy declaratively inside ProductDetail.cs and got the same error.

     
    Any other ideas? 

    Thanks,
    Brad
     

     

  • Re: Custom Controls, DLLs, ScriptManager and Update Panels

    12-12-2007, 10:12 AM

    If you use a scriptmanagerproxy on the page then the component should work.

     This should allow the inherited page to communicate with the parent scriptmanager
     

     For more info on the scriptmanagerproxy see:

    http://www.asp.net/learn/ajax-videos/video-95.aspx or http://msdn2.microsoft.com/en-us/library/system.web.ui.scriptmanagerproxy(VS.90).aspx

     


     

  • Re: Custom Controls, DLLs, ScriptManager and Update Panels

    07-31-2008, 8:53 PM
    • Loading...
    • silverjoe
    • Joined on 07-31-2008, 8:49 PM
    • Posts 1

    Did you ever find a solution to this problem?

    I've done much the same with no solution either; ScriptManagerProxy has made zero difference.

     

Page 1 of 1 (5 items)
Microsoft Communities
Page view counter