开发者

Enable disable tabs in a tab container

开发者 https://www.devze.com 2023-01-14 14:52 出处:网络
I have a tab container in aspx page and i want to enable disable the last tab in aspx page my tab container is like below

I have a tab container in aspx page and i want to enable disable the last tab in aspx page my tab container is like below

<asp:TabContainer runat="server" ID="tabCon开发者_如何学JAVAtainer">
<asp:TabPanel runat="server" ID="tabSettings" HeaderText="Settings">
<HeaderTemplate>Settings</HeaderTemplate>
<ContentTemplate>
<spsp:SlidingParametersSettingsPage ID="SlidingParametersSettingsPage" runat="server" />
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel runat="server" ID="tabRegionSelectionSettings" HeaderText="Exclude / Include Regions">
<HeaderTemplate>Exclude / Include Regions</HeaderTemplate>
<ContentTemplate>
<rssp:RegionSelectionSettingsPage ID="RegionSelectionSettingsPage" runat="server" />
</ContentTemplate>
</asp:TabPanel>
<asp:TabPanel runat="server" ID="tabAdvanceSettings" HeaderText="Advance Settings">
<HeaderTemplate>Advance Settings</HeaderTemplate>
<ContentTemplate>
<sfpsp:SmokeFireParametersSettingsPage ID="SmokeFireParametersSettingsPage" runat="server" />
<ssp:SakbotSettingsPage ID="SakbotSettingsPage" runat="server" />
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>

<script language="javascript" type="text/javascript">
    $find('<%=tabContainer.ClientID%>').get_tabs()[2].set_enabled(false);
</script>

Now for disabling the last tab i used the following in code behind page load:

//tabAdvanceSettings.Enabled = false;

I also want to enable this tab panel on client side when a user uses a shotrcut like Ctrl + Shif + A as shown below but this shortcut only enables the tab not the two user controls ptresent in the last tab. The code for enabling the last tab is :

if (e.keyCode == 65 && isCtrl == true && isShift == true) // Ctrl + Shift + A
{
    $find('<%=tabContainer.ClientID%>').get_tabs()[2].set_enabled(true);            
}

How can i enable the last tab and also the controls present in the last tab?


When you disable the tab from server side, it will disable all constituents children as server side. So what you need to do here is to emit start-up java-script to disable the tab at client side. At server side, tab and all its child controls will always remain in enabled state.


I have resolved the problem by placing the following code in javascript at the end of the page just before the </asp:content>

var tc = document.getElementById('<%= tabContainer.ClientID %>'); tc.firstChild.childNodes[2].style.visibility = "hidden";
0

精彩评论

暂无评论...
验证码 换一张
取 消