Hi basil1186,
The cause of this issue is when the TabContainer is rendered, the visible property of the controls inside the hidden TabPanel may be set as false. That is why the ComboBox is rendered in error if it is placed in to the hidden TabPanel. My last reply is a workaround which is setting the ComboBox’s TabPanel as the selected Tab firstly, and then changing the TabIndex to the others in the client pageLoad function.
If there are many ComboBoxes in each hidden TabContainer, I recommend you add the ComboBox from code behind side.
.aspx file
<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="TestInTabPanel.aspx.vb"
Inherits="SoluTest_ComboBox.TestInTabPanel" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<cc1:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" AutoPostBack="True">
<cc1:TabPanel runat="server" HeaderText="TabPanel1" ID="TabPanel1">
<ContentTemplate>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel runat="server" HeaderText="TabPanel2" ID="TabPanel2">
<ContentTemplate>
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel3" runat="server" HeaderText="TabPanel3">
<ContentTemplate>
</ContentTemplate>
</cc1:TabPanel>
</cc1:TabContainer>
</ContentTemplate>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>
.aspx.vb file
Imports AjaxControlToolkit
Partial Public Class TestInTabPanel
Inherits System.Web.UI.Page
Private Sub TabContainer1_ActiveTabChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabContainer1.ActiveTabChanged
If TabContainer1.ActiveTabIndex = 1 Then
Dim ComboBox1 As New ComboBox
ComboBox1.ID = "ComboBox1"
ComboBox1.DropDownStyle = ComboBoxStyle.DropDownList
ComboBox1.AutoCompleteMode = ComboBoxAutoCompleteMode.Suggest
ComboBox1.AppendDataBoundItems = False
ComboBox1.Items.Add("111111")
ComboBox1.Items.Add("111111")
ComboBox1.Items.Add("sdgferg")
ComboBox1.Items.Add("vcvdb")
ElseIf TabContainer1.ActiveTabIndex = 2 Then
Dim ComboBox2 As New ComboBox
ComboBox2.ID = "ComboBox2"
ComboBox2.DropDownStyle = ComboBoxStyle.DropDownList
ComboBox2.AutoCompleteMode = ComboBoxAutoCompleteMode.Suggest
ComboBox2.AppendDataBoundItems = False
ComboBox2.Items.Add("22222")
ComboBox2.Items.Add("22222")
ComboBox2.Items.Add("465465")
ComboBox2.Items.Add("3e2r3r2")
End If
End Sub
End Class
Best regards,
Zhi-Qiang Ni