Welcome Guest Search | Active Topics | Sign In | Register

TabStrip - changing state of tab items manually Options
WellThoughtOut
Posted: Wednesday, November 28, 2007 4:47:10 AM
Rank: Newbie
Groups: Member

Joined: 11/28/2007
Posts: 5
Hi, can anyone help me.

I have defined a tab strip with some sub tabs. I have set the AutoSelectSource="NavigateUrl" so that the tab gets the correct state when navigating to URL's however I want to set the state manually on some other pages that aren't listed on the tab menu.

e.g. I have a grid of data on one menu item with an edit option. When I click the edit option it takes me to a page to edit the grid item, but I lose the original tab state as the url now doesn't match the tab url. So I want to allow this edit page to change the state of a tab item.

BTW this is VB rather than C#

Thanks
Mark
eo_support
Posted: Wednesday, November 28, 2007 6:11:23 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi Mark,

You can always change the selected tab manually by setting the TabStrip's SelectedIndex property. If you also use AutoSelectSource, you may want to turn off AutoSelectSource when you set SelectedIndex. For example:

TabStrip1.AutoSelectSource = NavigatorAutoSelectSource.None
TabStrip1.SelectedIndex = 5

Thanks
WellThoughtOut
Posted: Wednesday, November 28, 2007 6:30:09 AM
Rank: Newbie
Groups: Member

Joined: 11/28/2007
Posts: 5
Hi,

I'm using the TabStrip as a navigation control included on each page, is this still possible?

Thanks
Mark
eo_support
Posted: Wednesday, November 28, 2007 6:37:21 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
It's possible. You just need to put it inside an If statement so that you only change it when you need to and for the rest you still rely on AutoSelectSource.
WellThoughtOut
Posted: Wednesday, November 28, 2007 6:57:26 AM
Rank: Newbie
Groups: Member

Joined: 11/28/2007
Posts: 5
So basically in my navigation control I need to retrieve the current page name and then if matching I need to set the selected index manually. I therefore need to do this for all those pages not directly accessible from the menu?

Is this the best way to achieve this?
eo_support
Posted: Wednesday, November 28, 2007 9:55:37 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,088
Hi,

I am not sure whether I followed your question correctly. My understanding is that when there is no matching you need to set the selected index manually. For example, you have two tab's NavigateUrl set to Page1.aspx and Page2.aspx, and when you navigate to Page2.aspx, the second tab is automatically selected. Now you navigate to Page3.aspx, the tab strip will default back to the first tab. In this case you want to Page2.aspx to be selected.

ASP.NET provides view state for controls to retain state information within the same page. When you navigate to another page (or re-fetch the same page via a HTTP GET, not a HTTP POST). All the state information is discarded. Our TabStrip offered two additional mechanisms to help you to sustain state information across different pages:

1. AutoSelectSource as you have already discovered;
2. SaveStateCrossPages property;

You can use either one, but you won't be able to use them together. The second option might help you. If what you need is beyond these two options, then you will have to implement your own logic and set SelectedIndex manually.

Thanks
WellThoughtOut
Posted: Wednesday, November 28, 2007 10:21:12 AM
Rank: Newbie
Groups: Member

Joined: 11/28/2007
Posts: 5
Thanks for all your help.


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.