2
我有一個帶有兩個選項卡的tabcontainer。第一個選項卡包含一個文本框,而第二個選項卡包含一個面板。在tabcontainer中啓用tabpanel
我希望在第一次加載頁面時禁用第二個選項卡,並且我希望在用戶在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;
}
}
你可能需要將整個tab容器放入updatepanel以允許更新面板啓用/禁用子控件 – rt2800
我試過了,但它仍然無效......除非我沒有正確地做。你能給我一個你的建議的代碼快照嗎?謝謝! – Mayou
對不起,我把我以前的評論回來!有用!!非常感謝! – Mayou