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