Wednesday, March 21, 2012

TabContainer losing ActiveTab State in UpdatePanel

Hi there folks,

I'm not sure that issue hadn't been described in the forums yet; it seems simple enough, yet I'm stuck, and can't find posts that aren't about the contrary (TabContainers with UpdatePanl inside...)

My problem is so:

I have an UpdatePanel containing a Panel, which contains, a TabContainer (whose tabpanels contain updatepanels of their own, that in turn contain WebUserControl.

Demonstration (I've cut it short, there, just to have something that shows the structure; that wouldn't compile...):

<asp:UpdatePanel>
<ContentTemplate>
<asp:Panel ID="pnlCurFolder" Visible="false">
<libAJAX:TabContainer OnClientActiveTabChanged="UserTabChanged"OnActiveTabChanged="tcFolders_OnActiveTabChanged">
<libAJAX:TabPanelID="tpGen"runat="server"HeaderText="Général">
<ContentTemplate>
<asp:UpdatePanelID="upnlClient"runat="server"RenderMode="Inline"UpdateMode="Conditional">
<ContentTemplate>
<wuc:ClientInfosID="wucCli"runat="server"Width="600px"/>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</libAJAX:TabPanel>
<libAJAX:TabPanelID="tpCar"runat="server"HeaderText="Vehicule">
<ContentTemplate>
<asp:UpdatePanelID="upnlcar"runat="server"RenderMode="Inline"UpdateMode="Conditional">
<ContentTemplate>
<wuc:CarInfosID="wucCar"runat="server"Width="600px"/>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</libAJAX:TabPanel> <libAJAX:TabPanelID="tpGen"runat="server"HeaderText="Général"OnClientClick="UserTabClicked">
<ContentTemplate>
<asp:UpdatePanelID="upnlClient"runat="server"RenderMode="Inline"UpdateMode="Conditional">
<ContentTemplate>
<wuc:ClientInfosID="wucCli"runat="server"Width="600px"/>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</libAJAX:TabPanel>
</libAJAX:TabContainer>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>

Since I need to do some work on Server side when changing tab, I added a JS function that calls __doPostBack on "OnClientActiveTabChanged". So far, so good, that part works fine. Problem is when I get back from the postback, the ActiveTab isn't persisted.

After a few other tries, I found out that if the pnlCurFolder (the asp:Panel containing the Container) begun with visible=false, then it shows up when it musts (after I select the Client Folder, or create a new one) but the ActiveTab will not be persisted and I'm condemned to watch it flicker back to the first tab after each post back, but if the panel starts with visible = true; then everything works fine... (the ActiveTab is maintained across postbacks...)

Any ideas as to why this is?

And if I use Control.Style[HtmlWriterStyle.Visibility] = "visible" or "hidden", it is just disregarded...

And it makes me sad!


Hi,

Please try display property instead:

pnlCurFolder.Style[HtmlTextWriterStyle.Display] = "none";

No comments:

Post a Comment