Showing posts with label selection. Show all posts
Showing posts with label selection. Show all posts

Saturday, March 24, 2012

Tabcontainer - Setting Tab Visibilities

Hi

I have a tabcontainer with several tabs on ajaxaed page. I am trying to hide some tabs at postabacks according to selection made in a dropdown list. Everything works fine until some of the tabs receive focus, e.g. if I hit the button inside the panel (I am using update panel hence there is no postback) . In that case when I change dropdown list selection, tabcontainer display gets messy.

I tested it in Firefox and the error line is marked in bold bellow:
set_activeTabIndex : function(value) {
if (!this.get_isInitialized()) {
this._cachedActiveTabIndex = value;
} else {
if (value < -1 || value >= this.get_tabs().length) {
throw Error.argumentOutOfRange("value");

From that I can conclude that the tabcontainer is trying to set tab that last received focus as active tab. Because the tabs visibilities are changed at postbacks the script fails. Please correct me if I am wrong.

Any help with this problem will be greatly appreciated.

OK there is a solution - I was led to it by reading this thread:

http://forums.asp.net/t/1068120.aspx?PageIndex=1

The member with nickname howeird posted the one way to solve the problem:

In my case I change the client side function from:

<script type="text/javascript">
function ActiveTabChanged(sender, e) {
var activeTab = $get('<%=activeTab.ClientID%>');
activeTab.value = sender.get_activeTabIndex();
}
</script>

To:
<script type="text/javascript">
function ActiveTabChanged(sender, e) {
var activeTab = $get('<%=activeTab.ClientID%>');
activeTab.value = 0;
}
</script>

That will ensure that the tab with index No 0 is always set as active tab at postbacks.
NOTE: The client side function is only part of the solution read the rest of the poste for full implementation.

Thanx howeird

Wednesday, March 21, 2012

TabContainer doesnt persist tab selection between postbacks

Hi,

I'm using a couple of TabContainers on my web form. The main TabContainer hosts seven TabPanels, each of which hosts a different FormView control.

According to the Tab documentation, "the most recent tab should remain selected after a postback." However, whenever I change the mode on a FormView (e.g. changing to Edit a record), a postback occurs and a the first tab is selected again.

I tried setting the TabContainer's EnableViewState="True", but that didn't help.

What do I need to do to keep the same tab selected between postbacks?

Thanks,

Mark

Anyone else seeing this problem? Any idea how to keep the tab selected between postbacks?

Thanks,

Mark


Hi Mark,

According to my test, the active index is persisted between postbacks.

If it doesn't for you, please try the following workaround.

1. Add a hidden field on the form

2. On the client side active index changed event, save current index into the hidden field

3. On postback, set the activeIndex of the tabContainer to the value in hidden field( on Server Side )

Or set it via javascript in client side pageLoad event.

Hope this helps.


Thank you Raymond. Sorry for the late reply; I have been distracted with other tasks. I'll try this when I get back to working on the UI.

Mark