title: How to use same user control multiple times in aspx page
body: <p>How to use same user control multiple times in aspx page and load the user control on tab click. </p>
  
  <p>I've defined an user control(UDTControl.ascx) and declared it in each tab panel. On tab click, based on tab index I'm passing the tabname to ascx function and the call the sp to load data in the table.</p>
  
  <pre><code>&lt;%@ Page Language="C#" AutoEventWireup="true" CodeBehind="temp.aspx.cs" Inherits="WebUI.temp" %&gt;
  &lt;%@ Register Src="Shared/UDTControl.ascx" TagName="UDTControl" TagPrefix="UserControl" %&gt;
  &lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %&gt;
  
  &lt;asp:Content ID="Content1" ContentPlaceHolderID="PublicContent" runat="server"&gt;
    &lt;script type="text/javascript"&gt;
         function ActiveTabChanged(sender, e) {
             var ActiveIndex = sender.get_activeTabIndex();
             if (ActiveIndex == 0) {
                 UDTControlFuncAscx("abc");
             }
             if (ActiveIndex == 1) {
                 UDTControlFuncAscx("xyz");
             }
             if (ActiveIndex == 2) {
                 UDTControlFuncAscx("mno");
             }
         }
   &lt;/script&gt;
    &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
      &lt;ContentTemplate&gt;
        &lt;cc1:TabContainer ID="DashboardContainer" runat="server"OnClientActiveTabChanged="ActiveTabChanged" &gt;
               &lt;cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="abc"&gt;
                   &lt;UserControl:UDTControl ID="id1" runat="server"/&gt;
               &lt;/cc1:TabPanel&gt;
               &lt;cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="xyz"&gt;&gt;
                     &lt;UserControl:UDTControl ID="id2" runat="server"/&gt;
               &lt;/cc1:TabPanel&gt;
               &lt;cc1:TabPanel ID="TabPanel3" runat="server" HeaderText="mno"&gt;&gt;
                     &lt;UserControl:UDTControl ID="id3" runat="server"/&gt;
                &lt;/cc1:TabPanel&gt;                
       &lt;/ContentTemplate&gt;
  &lt;/asp:UpdatePanel&gt;
  &lt;/asp:Content&gt;
  </code></pre>
  
  <p>and following is my ascx code</p>
  
  <pre><code>&lt;%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UDTControl.ascx.cs" Inherits="WebUI.Shared.UDTControl" %&gt;
  &lt;%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %&gt;
  
  &lt;%@ Register Assembly="WebUI" TagPrefix='SFX' Namespace='WebUI.Shared' %&gt;
  
   &lt;script type="text/javascript"&gt;
       function DashboardFuncAscx(ActiveTab) {
           if (ActiveTab == "abc") {
           //call abc sp using page method and load data on table
           }
           if (ActiveTab == "xyz") {
               //call xyz sp and load on table
           }
       }
   &lt;/script&gt;
  
  &lt;asp:UpdatePanel ID="DashboardPanel" runat="server"&gt;
      &lt;ContentTemplate&gt;
           &lt;asp:Panel ID="Dashboard1" runat="server"&gt;
               &lt;table id="tableid" &gt; &lt;/table&gt;
          &lt;/asp:Panel&gt;
      &lt;/ContentTemplate&gt;          
  &lt;/asp:UpdatePanel&gt;
  </code></pre>
  
  <p>Currently, I'm facing an issue with above logic. This is working fine for first tab, but when i click on second tab SP is triggered and data is also fetched but  the result is not showing bcz result is loaded on the first tab user control.</p>