繁体   English   中英

在tabcontainer中启用tabpanel

[英]Enable tabpanel in tabcontainer

我有一个带有两个标签的tabcontainer。 第一个选项卡包含一个文本框,而第二个选项卡包含一个面板。

我希望在第一页加载时禁用第二个选项卡,并且我希望用户在tab1的文本框中输入一个输入后立即启用它。 当再次清空tab1中的文本框时,应再次禁用第二个选项卡。

我尝试了以下代码,但是无论如何,第二个选项卡仍然处于禁用状态。 任何帮助,将不胜感激。 谢谢!

aspx

<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="4" HeaderText=""
    Height="578px" Width="900px" TabStripPlacement="Top" ScrollBars="None" UseVerticalStripPlacement="false"
    VerticalStripWidth="120px" BackColor="White" BorderColor="White" Style="margin-right: 84px">
    <asp:TabPanel ID="TabPanel1" runat="server">
        <HeaderTemplate>
            General
        </HeaderTemplate>
        <ContentTemplate>
             <asp:UpdatePanel ID="TestUpdatePanel" runat="server">
                <ContentTemplate>
                        <table style="height: 247px; width: 100%;">
                            <tr>
                                  <td>
                                       <asp:TextBox ID="HorizonTextBox" runat="server" OnTextChanged="HorizonTextBox_TextChanged"
                                                    AutoPostBack="True"></asp:TextBox>
                                  </td>
                            </tr>
                         </table>
                </ContentTemplate>
             </asp:UpdatePanel>
        <ContentTemplate>
     </asp:TabPanel>
     <asp:TabPanel ID="TabPanel2" runat="server">
         <HeaderTemplate>
            Dashboard
        </HeaderTemplate>
        <ContentTemplate>
            <asp:Button ID="RunSimulationButton" runat="server" Text="Run Simulation" OnClick="RunSimulationButton_OnClick" />
            <br />
            <br />
            <asp:Panel ID="PlotPanel" runat="server">
            </asp:Panel>
        </ContentTemplate>
    </asp:TabPanel>

aspx.cs

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            TabContainer1.ActiveTabIndex = 0;

            TabPanel2.Enabled = false;

        }
    }

    protected void HorizonTextBox_TextChanged(object sender, EventArgs e)
    {
        if(HorizonTextBox.Text != "")
        {
              TabPanel2.Enabled = true;
        }
    }

您可能需要将整个选项卡容器包含在updatepanel中,以允许更新面板启用/禁用子控件

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM