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

TabStrip persisting content and selected tab on refresh

3 Answers 270 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
MPatt
Top achievements
Rank 1
MPatt asked on 26 Oct 2010, 09:16 AM
Hi, I am replacing an existing control suite with Telerik and am trying to use the tabstrip to control navigation, with each tab pointing to a .Net page that isn't suitable to be put into a multipage due to complexity.

I found a suggestion in the forums to use an iframe which I have done but I find that when the page is refreshed the selected tab goes back to the first tab and trying to interrogate the iframe src using jquery just seems to bring back the intiailly set src.

Is there a way to persist the selected tab on page refresh?

My code is below.

Thanks, Matt

<telerik:RadTabStrip ID="rtsMainTabs" runat="server" Width="990px"
    CssClass="crmMainTabs" Skin="Simple" SelectedIndex="2">
    <Tabs>                      
        <telerik:RadTab
            NavigateUrl="home.aspx"
            Text="Front Page"
            Target="IFContent">
        </telerik:RadTab>
        <telerik:RadTab
            NavigateUrl="Page2.aspx"
            Text="Page2"
            Target="IFContent">
        </telerik:RadTab>
        <telerik:RadTab
            NavigateUrl="Page3.aspx"
            Text="Page3"
            Target="IFContent">
        </telerik:RadTab>
        <telerik:RadTab
            NavigateUrl="Page4.aspx"
            Text="Page4"
            Target="IFContent">
        </telerik:RadTab>
    </Tabs>
</telerik:RadTabStrip>
<iframe name="IFContent" id="IFContent" style="width:990px; height:720px;"
src="home.aspx"></iframe>

3 Answers, 1 is accepted

Sort by
0
Cori
Top achievements
Rank 2
answered on 26 Oct 2010, 01:27 PM
Hello MPatt,

Instead of using an iFrame to navigate between the different pages. Why don't you just add the TabStrip to a MasterPage and add that master page to each of those pages. Then in the master page you can use this approach to select the correct tab based on the url:

http://demos.telerik.com/aspnet-ajax/tabstrip/examples/applicationscenarios/sitenavigation/defaultcs.aspx

I hope that helps.
0
MPatt
Top achievements
Rank 1
answered on 26 Oct 2010, 03:02 PM
Hi, thanks for the suggestion.  I am trying to replace an existing control suite without making too many other changes currently but I can see the benefit of using a MasterPage - personally I really don't like iframes but it seemed like a necessary compromise.

There is an added layer of complexity in that one of the pages loaded from the tabstrip has its own tabstrip so I would need a solution for nested tabstrips which I am not sure the masterpage approach would handle. iframes within iframes - not ideal...

I think that longer term we will revisit the application and refactor it properly but I need a sort of stop gap solution for now.

Thanks,

Matt
0
Cori
Top achievements
Rank 2
answered on 27 Oct 2010, 03:18 PM
In that case, why not add a HiddenField to the page and when a tab is changed you can set which is selected in the HiddenField. Then, on every postback, you re-select the tab and set the url of the iFrame.

I think that should work.
Tags
TabStrip
Asked by
MPatt
Top achievements
Rank 1
Answers by
Cori
Top achievements
Rank 2
MPatt
Top achievements
Rank 1
Share this question
or