title: Using AjaxControlToolkit Accordion control in User control that dynamically added to page in asp.net
body: <p>Hi I am trying to use AjaxControlToolkit's Accordion control in user control. That user control is added to page dynamically from code behind. My code for user control is as follows:</p>
  
  <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyControl.ascx.cs" 
  Inherits="Project.UC.Control" %&gt;
  
  &lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit"
  TagPrefix="asp" %&gt;
  
  &lt;asp:Accordion ID="Accordion1" runat="server" HeaderSelectedCssClass="Sel" 
  HeaderCssClass="unSel" SelectedIndex="0"&gt;
  &lt;Panes&gt;
  &lt;asp:AccordionPane runat="server" ID="AccordionPane1"&gt;  
  &lt;Header&gt;Red Orchid&lt;/Header&gt;  
  &lt;Content&gt;Some content here.&lt;/Content&gt;  
  &lt;/asp:AccordionPane&gt;  
  &lt;/Panes&gt;
  &lt;/asp:Accordion&gt;
  </code></pre>
  
  <p>To add user control dynamically I used following code in my page's code behind</p>
  
  <pre><code>Control mycontrol = this.LoadControl("~/myUserControl.ascx");
  this.Controls.Add(mycontrol);
  </code></pre>
  
  <p>On my user control consumer page I have form tag with runat="server" also added ScriptManager control for ajax functionality. When I run my code I am getting following error </p>
  
  <pre><code>Control 'ctl02_Accordion1_AccordionExtender' of type 
  'AccordionExtender' must be placed inside a form tag with runat=server. 
  </code></pre>
  
  <p>I already used form with runat="server" tag on my consumer page why this problem is coming. To solve this problem I moved my consumer page's form tag to user control this solves my problem but by doing this I can't take advantage of postback on my consumer page. If I put form tag with runat="server" in both user control and consumer page it show error that you can use only one form tag on page. How to solve this problem.</p>
  
  <p>Thanks in advance..</p>