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

How can I preserve RadTab selectedindex?

1 Answer 164 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
chris lively
Top achievements
Rank 1
chris lively asked on 17 Jun 2010, 04:32 PM
I have a RadTabStrip with 3 tabs

There is one RadMultiPage with 3 RadPageViews (one for each tab).
Inside each individual page view is a RadToolBar.  The toolbar links to other pages within that section of the app.

When I click on one of the RadToolBarButton's, it resets the selected tab.

How can I preserve the currently selected tab when different toolbarbuttons are clicked?

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 18 Jun 2010, 09:34 AM
Hello Chris,

I guess you are redirecting to new page on clicking the RadToolBar button and RadTabStrip SelectedIndex is not preserved on the new page (which contains same controls as well). If that, the case, you need to set the SelectedIndex explicitly after redirecting.

One suggestion to set the correct SelectedIndex is by passing the index as url parameter when redirecting itself. The following code shows how to add url parameter when redirecting.
CS:
 
    protected void RadToolBar2_ButtonClick(object sender, RadToolBarEventArgs e) 
    { 
        Response.Redirect("NewPage.aspx?id="+ RadTabStrip1.SelectedIndex); 
    } 


Now in the Page_Load event of NewPage.aspx, you can easily reset the RadTabStrip SelectIndex. Here is code snippet on how to perform this.

CS:
 
    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (Page.Request["id"] != null
        { 
            RadTabStrip1.SelectedIndex = Convert.ToInt32(Page.Request["id"]); 
            RadMultiPage1.SelectedIndex = RadTabStrip1.SelectedIndex; 
        } 
    } 

Could you provide some more information about your scenario, if that is different than what I tried?

Regards,
Princy
Tags
TabStrip
Asked by
chris lively
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Share this question
or