0

I have an ajax tabcontainer in an updatepanel with all tabpages set visible until you want to add a tabpanel based on the dropdownlist selected value CODE:

<cc1:TabContainer ID="tabControlParameters" runat="server" CssClass="ajax__tab_xp"
                            ScrollBars="Both" ActiveTabIndex="15" UseVerticalStripPlacement="True">
                            <%--EnvironmentTab --%>
                            <cc1:TabPanel ID="pnlEnvironment" HeaderText="Environment" runat="server" Visible="false">
                                <ContentTemplate>
                                   //somecontent
                                </ContentTemplate>
                            </cc1:TabPanel>
                            <cc1:TabPanel ID="pnlDatabase" HeaderText="Environment" runat="server" Visible="false">
                                <ContentTemplate>
                                   //somecontent
                                </ContentTemplate>
                            </cc1:TabPanel>
                            <cc1:TabPanel ID="pnlFirstError" HeaderText="Environment" runat="server" Visible="false">
                                <ContentTemplate>
                                   //somecontent
                                </ContentTemplate>
                            </cc1:TabPanel>

With a button add which is inside the Updatepanel and has a correct async trigger assigned to it.

From C# codebehind I've made a loop to check if the dropdownlist selectedvalue = panel_headertext if so make it visible CODE:

protected void btnAddParameters_Click(object sender, EventArgs e)
    {
        String Parameter = ddlParameterTypes.SelectedValue.ToString();
        AjaxControlToolkit.TabContainer container = (AjaxControlToolkit.TabContainer)tabControlParameters;

        foreach (object obj in container.Controls)
        {
            if (obj is AjaxControlToolkit.TabPanel)
            {
                AjaxControlToolkit.TabPanel tabPanel = (AjaxControlToolkit.TabPanel)obj;
                if (tabPanel.HeaderText == ddlParameterTypes.SelectedValue)
                {
                    tabPanel.Visible = true;
                    tabPanel = tabControlParameters.ActiveTab;
                    container.ActiveTab = tabPanel;

                }   
            }   
        }
    }

Now this works perfectly if the updatepanel trigger is set to fullPostback but it's set to async postback then it only works on the first click even though the event is fired every time I'm clicking on the button. Am I missing something obvious here? Petar

Petar
  • 47
  • 1
  • 6
  • Have a look at my old answer [here](http://stackoverflow.com/questions/6029648/ajax-tookit-tabpanel-invisible-tag-bug), maybe it is related and helpful. Jerry Weng provided a C# version [here](http://forums.asp.net/t/1620618.aspx). I don't know if that bug is fixed meanwhile. – Tim Schmelter May 19 '15 at 12:05
  • I pasted the code behind my foreach loop, but it did nothing. Tried changing the word "container" to my tabcontainerID and still no change. Am I doing something wrong? – Petar May 19 '15 at 12:17

1 Answers1

0

You have the same value in HeaderText for each of your TabPanels. I think it'll work if you correct the HeaderText attributes.

Skye MacMaster
  • 894
  • 1
  • 10
  • 19
  • Oh right,well the headertext in the actual code is correct, I just took the first tabpage, removed the content and copy pasted it 3 times :p – Petar May 19 '15 at 14:21