tags:

views:

160

answers:

1

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="tabContainer">
<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?

+1  A: 

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.

VinayC
I have ammended the code as shown above in my post above by commenting the page load event code for disabiling the panel and using javascript to disable the tab panel.Now instead of opening the page it displays Microsoft JScript rutime error: null or not an object - on the following line which i have recently added as shown below<script language="javascript" type="text/javascript"> $find('<%=tabContainer.ClientID%>').get_tabs()[2].set_enabled(false);</script>
Rahat Ali
Issue here is that your script is running before AJAX tabs are initialized. You have to emit start-up script (either using ScriptManager.RegisterStartupScript or Page.ClientScript.RegisterStartupScript based on whether its normal post-back or AJAX post-back). Start-up scripts are get placed at the end of page html (so they get invoked late). Its best if you can wrap this script in pageLoad function (see http://encosia.com/2007/08/01/simplify-aspnet-ajax-client-side-page-initialization/).
VinayC
Thankx for your help 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";
Rahat Ali