locked
Please Help to call event in a loop for AjaxControlToolkit.TabContainer RRS feed

  • Question

  • User-1868929400 posted

    Hi All,

    I am trying to call event in a loop for below code.

     for (int i = 0; i < 4; i++)
            {
                AjaxControlToolkit.TabContainer tab = new AjaxControlToolkit.TabContainer();
                tab.ID = "Tabs" + i;
                tab.Height = 200;
                tab.OnClientActiveTabChanged = "how to write code for event here()";
     at.ContentTemplate= true how to assign property ContentTemplate to reference at }

    But I dont know the syntax for it.

     Please help me.

    Regards,

    Jayesh.(From India,Mumbai)

    Monday, June 23, 2014 3:39 AM

Answers

  • User-1353043493 posted
    for (int i = 0; i < 4; i++)
    {
        AjaxControlToolkit.TabContainer tab = new AjaxControlToolkit.TabContainer();
        tab.ID = "Tabs" + i;
        tab.Height = 200;
        tab.OnClientActiveTabChanged += TabContainer1_ActiveTabChanged;
    }
    
    
    void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
    {
        if(TabContainer.ActiveTabIndex == 2){
        //Code hereTabContainer
        }
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2014 5:10 AM
  • User-1353043493 posted
    user control 
    
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TabContentTemplateTest.ascx.cs" Inherits="WebGUI.TabContentTemplateTest" %>
    
    .CS of user control
    public partial class TabContentTemplateTest : UserControl, ITemplate
    {
        public void InstantiateIn(Control container)
        {
            container.Controls.Add(this);
        }
    }
    
    
    Your page code
    for (int i = 0; i < 4; i++)
    {
        AjaxControlToolkit.TabContainer tab = new AjaxControlToolkit.TabContainer();
        tab.ID = "Tabs" + i;
        tab.Height = 200;
        tab.OnClientActiveTabChanged += TabContainer1_ActiveTabChanged;
        var tabContent = LoadControl("~/TabContentTemplateTest.ascx") as TabContentTemplateTest;
        tab.ContentTemplate=tabContent;
    }
    
    
    void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
    {
        
    }
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2014 5:41 AM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2014 7:08 AM
  • User-1868929400 posted

    Hi Dharmesh,

    Thanks for the link.

    That's what I was looking for.

    Thanks a lot.

    Regards,

    Jayesh(From India,Mumbai) .

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2014 7:25 AM

All replies

  • User-1353043493 posted
    for (int i = 0; i < 4; i++)
    {
        AjaxControlToolkit.TabContainer tab = new AjaxControlToolkit.TabContainer();
        tab.ID = "Tabs" + i;
        tab.Height = 200;
        tab.OnClientActiveTabChanged += TabContainer1_ActiveTabChanged;
    }
    
    
    void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
    {
        if(TabContainer.ActiveTabIndex == 2){
        //Code hereTabContainer
        }
    }

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2014 5:10 AM
  • User-1868929400 posted

    Thanks Dharmesh,

    But above solution is not working its giving error.

    Can You Please Help me also to asssign contenttemplate property  to AjaxControlToolkit.TabPanel reference. which is at in this case.

     
    Monday, June 23, 2014 5:19 AM
  • User-1353043493 posted
    user control 
    
    <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="TabContentTemplateTest.ascx.cs" Inherits="WebGUI.TabContentTemplateTest" %>
    
    .CS of user control
    public partial class TabContentTemplateTest : UserControl, ITemplate
    {
        public void InstantiateIn(Control container)
        {
            container.Controls.Add(this);
        }
    }
    
    
    Your page code
    for (int i = 0; i < 4; i++)
    {
        AjaxControlToolkit.TabContainer tab = new AjaxControlToolkit.TabContainer();
        tab.ID = "Tabs" + i;
        tab.Height = 200;
        tab.OnClientActiveTabChanged += TabContainer1_ActiveTabChanged;
        var tabContent = LoadControl("~/TabContentTemplateTest.ascx") as TabContentTemplateTest;
        tab.ContentTemplate=tabContent;
    }
    
    
    void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
    {
        
    }
    

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2014 5:41 AM
  • User-1868929400 posted

    Hi Dharmesh,

    Your code works for user control but how to use same code for single control like 

    <asp:Image ID="p1"  runat="server" />

    Will you please tell me that.Because I want to create image control in a loop

    Monday, June 23, 2014 6:16 AM
    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2014 7:08 AM
  • User-1868929400 posted

    Hi Dharmesh,

    Thanks for the link.

    That's what I was looking for.

    Thanks a lot.

    Regards,

    Jayesh(From India,Mumbai) .

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 23, 2014 7:25 AM