locked
Why The tab container ActiveTabChanged event fired by the internal control changed events? RRS feed

  • Question

  • User-504606082 posted

    Sir,

    The below is my design:

    <asp:TabContainer ID="Tabcontainer" runat="server" AutoPostBack="true" ForeColor="Gray" CssClass="ajax__tab_custom" Height="100%" Width="100%" OnActiveTabChanged="Tabcontainer_ActiveTabChanged" >

    <asp:TabPanel ID="Tabpnlplasma" runat="server" >
    <HeaderTemplate>Tab1</HeaderTemplate>

    <ContentTemplate>

    <asp:DropDownList ID="d1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="d1_SelectedIndexChanged" >
    <asp:ListItem></asp:ListItem>
    <asp:ListItem>1</asp:ListItem>

    <asp:ListItem>2</asp:ListItem>
    </asp:DropDownList><br />
    <asp:ListBox ID="l1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="l1_SelectedIndexChanged">
    <asp:ListItem>1</asp:ListItem>
    <asp:ListItem>2</asp:ListItem>
    <asp:ListItem>3</asp:ListItem>
    </asp:ListBox>
    </ContentTemplate>
    </asp:TabPanel>

    <asp:TabPanel ID="TabPanel1" runat="server">
    <HeaderTemplate>Tab2</HeaderTemplate>

    <ContentTemplate>

    <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
    <asp:ListItem></asp:ListItem>
    <asp:ListItem>1</asp:ListItem>

    <asp:ListItem>2</asp:ListItem>
    </asp:DropDownList><br />
    <asp:ListBox ID="ListBox1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged">
    <asp:ListItem>1</asp:ListItem>
    <asp:ListItem>2</asp:ListItem>
    <asp:ListItem>3</asp:ListItem>
    </asp:ListBox>
    </ContentTemplate>
    </asp:TabPanel>
    </asp:TabContainer>

    Here my problem is when i select the Tab1 dropdown or listbox two events are fire one is dropdown or listbox and another is ' tabcontainer active tab changed event'.

    When i repeat this same process in tab2 the Tab container event not fired. Why this tab container event fired . please help me sir.

    Tuesday, December 3, 2013 4:24 AM

Answers

  • User-417640953 posted

    Hi saikumarneelam,

    Thank you post the issue to asp.net forum.

    If you want the "OnActiveTabChanged" of TabContainer , "OnSelectedIndexChanged" of DropDownList and "OnSelectedIndexChanged" of ListBox

    works fine. You should make sure the ViewState of them is ture. First of all, set your page EnableViewState="true".

    With above condition, I test your code and it works fine in my side.

       <asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></asp:ToolkitScriptManager>
            <asp:TabContainer ID="TabContainer1" runat="server" AutoPostBack="true" ForeColor="Gray" CssClass="ajax__tab_custom" 
                Height="100%" Width="100%" OnActiveTabChanged="TabContainer1_ActiveTabChanged" ActiveTabIndex="0"  >
                <asp:TabPanel ID="Tabpnlplasma" runat="server">
                    <HeaderTemplate>Tab1</HeaderTemplate> 
                     <ContentTemplate> 
                         <asp:DropDownList ID="d1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="d1_SelectedIndexChanged" >
                         <asp:ListItem>0</asp:ListItem>
                         <asp:ListItem>1</asp:ListItem> 
                         <asp:ListItem>2</asp:ListItem>
                         </asp:DropDownList><br />
                         <asp:ListBox ID="l1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="l1_SelectedIndexChanged">
                         <asp:ListItem>1</asp:ListItem>
                         <asp:ListItem>2</asp:ListItem>
                         <asp:ListItem>3</asp:ListItem>
                         </asp:ListBox>
                     </ContentTemplate> 
                </asp:TabPanel>
                <asp:TabPanel ID="TabPanel1" runat="server">
                     <HeaderTemplate>Tab2</HeaderTemplate> 
                     <ContentTemplate> 
                     <asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
                     <asp:ListItem>one</asp:ListItem>
                     <asp:ListItem>two</asp:ListItem>  
                     <asp:ListItem>three</asp:ListItem>
                     </asp:DropDownList><br />
                     <asp:ListBox ID="ListBox1" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ListBox1_SelectedIndexChanged">
                     <asp:ListItem>one</asp:ListItem>
                     <asp:ListItem>two</asp:ListItem>
                     <asp:ListItem>three</asp:ListItem>
                     </asp:ListBox>
                     </ContentTemplate> 
                </asp:TabPanel>
            </asp:TabContainer>

    Code behind:

       protected void TabContainer1_ActiveTabChanged(object sender, EventArgs e)
            {
                Response.Write("TabContainer1_ActiveTabChanged");
            }
    
            protected void d1_SelectedIndexChanged(object sender, EventArgs e)
            {
                Response.Write("d1_SelectedIndexChanged");
            }
    
            protected void l1_SelectedIndexChanged(object sender, EventArgs e)
            {
                Response.Write("l1_SelectedIndexChanged");
            }
    
            protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
            {
                Response.Write("DropDownList1_SelectedIndexChanged");
            }
    
            protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
            {
                Response.Write("ListBox1_SelectedIndexChanged");
            }

    Thanks.

    Best Regards!

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, December 5, 2013 10:16 PM