|
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
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
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
|
|
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
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
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.
|
|
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?
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,194
|
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
|
|
Rank: Newbie Groups: Member
Joined: 11/28/2007 Posts: 5
|
Thanks for all your help.
|
|