This is a migrated thread and some comments may be shown as answers.

RadTabStrip state lost after postback

2 Answers 220 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Paul Black
Top achievements
Rank 1
Paul Black asked on 18 Sep 2008, 12:33 PM
Hi,

I'm using a RadTabStrip to replace the Tab control in MS AJAX.  On the client/ radtabstrip I locate a tab and set it to invisible using myTab.set_visible(false).  This works until I click on a button that has to refresh the page using a post back.  Is there a way to enable the radtabstrip to remember it's state.  It was simply a matter of using EnableViewState using the MS AJAX tabs...

This is a show stopper for me and will mean I have to revert back to the MS toolkit.

Thanks for reading

2 Answers, 1 is accepted

Sort by
0
Paul
Telerik team
answered on 19 Sep 2008, 01:04 PM
Hi Paul,

Please find below a sample code snippet that shows the needed approach.

ASPX:
<form id="form1" runat="server">  
    <div> 
        <asp:ScriptManager ID="ScriptManager1" runat="server">  
        </asp:ScriptManager> 
    </div> 
 
    <script type="text/javascript">  
    function hideTab()  
    {  
        var tabstrip = $find('<%= RadTabStrip1.ClientID %>');  
        var myTab = tabstrip.findTabByText("Root RadTab2");  
        tabstrip.trackChanges();  
        if(myTab != null)  
        {  
            myTab.set_value("hidden");  
            myTab.hide();  
        }  
        tabstrip.commitChanges();  
    }  
    </script> 
 
    <telerik:RadTabStrip ID="RadTabStrip1" runat="server">  
        <Tabs> 
            <telerik:RadTab runat="server" Text="Root RadTab1">  
            </telerik:RadTab> 
            <telerik:RadTab runat="server" Text="Root RadTab2">  
            </telerik:RadTab> 
            <telerik:RadTab runat="server" Text="Root RadTab3">  
            </telerik:RadTab> 
        </Tabs> 
    </telerik:RadTabStrip> 
    <input id="Button2" type="button" value="disable tab" onclick="hideTab()" /> 
    <asp:Button ID="Button1" runat="server" Text="Button" /> 
</form> 

Code-behind:
protected void Page_Load(object sender, EventArgs e)  
{  
    foreach(RadTab myTab in RadTabStrip1.GetAllTabs())  
    {  
        if (myTab.Value == "hidden")  
        {  
            myTab.Visible = false;  
        }  
    }  


Kind regards,
Paul
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Paul Black
Top achievements
Rank 1
answered on 19 Sep 2008, 01:18 PM
Hi there.  Thanks for the reply.  I will try that.  I didn't solve the problem using the above.  basically a dropdown list triggeres the show/hide of a tab and so in my page_load I check that control and show/hide the tab on postback. works the same sort of way.

Would be good if there was somekindof property to set on  the control to remember it's state on postbacks.

All the best

Paul...
Tags
TabStrip
Asked by
Paul Black
Top achievements
Rank 1
Answers by
Paul
Telerik team
Paul Black
Top achievements
Rank 1
Share this question
or