Sunday, March 11, 2012

TabContainer tab + remembering on pastback

Hi,

when you redirect the user to an other page, you can't use the viewstate to memory some values. So i think a possible solution is to use a session variable to hold the last selected tab-id. When you have a Masterpage layout you can use a "global" hidden field. Or you put the selected tab-id as querystring parameter to the new link and then you can send this value back to the original page, e.g.:
newpage.aspx?tabid=2 later: comefrom.aspx?tabid=2

Regards
Marc Andre


that makes sense. Ok..next dumb question. How do I select the specifc tab?

is it 'Focus'?


You can set the active tab with the "ActiveTabIndex" property of the TabContainer in the page load event:

protected void Page_Load(object sender, EventArgs e){ TabsContainer.ActiveTabIndex = 1;}

excellent, thanks.

what would be a better path to achieve my goals?

1. Use javascript to append the selected index to my URLs?

2. Write a custom AJAX Script Manager to do this?



I think a simple javascript method is enougth to achieve your goals. For reuse purpose it is a good idea to implement a script component.

No comments:

Post a Comment