I have a web form with a webtab control which has five tabs. Each tab has several user controls.
If I'm on any tab (e.g. tab1) and I click to a different tab (e.g. tab2), the following happens:
1. The load event of every control on tab1 runs. (not normal to me)
2. The tab_click event runs. (normal to me)
3. The load event of every control on tab2 runs. (normal to me)
Why do all of the load events of the tab I'm leaving run? I've tried different attribute settings on the webtab which don't change this process.
Is this normal processing in the webtab control?
I've spent a lot of time looking at something similar not that long ago. Even when the tabs are set up to be asynchronous, tab 1 always gets loaded (all the user control events are fired). Actually, during first time render all tabs are loaded too when set to be asynchronous.
If you goal is lazy loaded tabs (not asynchrounous) you can leverage a hidden field to track the current active tab and code like the following:
protected void itbTabs_Click(object sender, Infragistics.WebUI.UltraWebTab.WebTabEvent e) { if (hfActiveTabIndex.Value != itbTabs.SelectedTabIndex.ToString()) { PopulateSelectedTab(itbTabs.SelectedTabIndex); hfActiveTabIndex.Value = itbTabs.SelectedTabIndex.ToString(); } } protected void itbTabs_Load(object sender, EventArgs e) { PopulateSelectedTab(Convert.ToInt32(hfActiveTabIndex.Value, CultureInfo.InvariantCulture)); }
private void PopulateSelectedTab(int selectedTabIndex) { Tab Tab = ((Tab)(itbTabs.Tabs[selectedTabIndex]));
//Only populate a tab once if (Tab.ContentPane.Controls.Count == 1) { switch (selectedTabIndex) { case 0: Control control1 = LoadControl("UserControls/Control1.ascx"); Tab.ContentPane.Controls.Add(control1); break; case 1: Control control2 = LoadControl("UserControls/Control2.ascx"); Tab.ContentPane.Controls.Add(control2 ); break; default: break; } } }
Just a cautionary note if asynchronous tabs were your goal: LinkButtons will not/may not successfully navigate to another page.
This sounds plausible, depending on Viewstate.
If ViewState is turned on, then when the control post back it would rehydrate from ViewState, which would Init the control and any sub controls as their viewstate would also be applied. Actually even without child viewstate on, if the Init on the Tab is firing the CreateChildControls would probably be firing as well, which would make the child controls.
I just wanted to forward this hypothsis, since you seem to be testing various properties. I am not a Tab expert however.