I have two tab and each tab I taken a place holder. So on tab index change property I am loading user control in respective place holder.
<ig:WebTab runat="server" ID="wbTab" Width="100%" Height="600px" OnSelectedIndexChanged="wbTab_SelectedIndexChanged"> <AutoPostBackFlags SelectedIndexChanged="On" /> <Tabs> <ig:ContentTabItem runat="server" Text="Client" TabSize="115px"> <Template> <asp:PlaceHolder runat="server" ID="plClient" /> </Template> </ig:ContentTabItem> <ig:ContentTabItem runat="server" Text="Notes" TabSize="115px"> <Template> <asp:PlaceHolder runat="server" ID="plNotes" /> </Template> </ig:ContentTabItem>.....................
Second User control contains a dropdown list and it going to autopostback. But on postback, tab is getting blank. It seems removing the current user control form the tab.
Please advise.
Hi Deepika,
I'm just following up to see if you need any further assistance with this issue. If so please do not hesitate to contact me!
Hello Deepika,
Thank you for posting in our forum. The second tab from the WebTab control is getting blank, because of the DropDownList (DDL) AutoPostBack. You are creating dynamically the DDL when switch between tabs in wbTab_SelectedIndexChanged event right? When AutoPostBack is performed the page content is recreated, except the DDL, because the DDL is created when you change tab. You need to handle the Page_Init event. From there add to the placeholder the DDL like this:
protected void Page_Init(object sender, EventArgs e) { DropDownList ddl = new DropDownList(); /* Configure ddl */ (wbTab.Tabs[1].FindChildControl("plNotes") as PlaceHolder).Controls.Add(ddl); }
Now, after the AutoPostBack, the DDL will initialize again with the selected value. The Init event will perform again and will recreate the DDL, and the ViewState of the page will keep the value that you've selected and will set it. Some further reference that I recommend you:
ASP.NET Page Life Cycle Overview and Understanding ASP.NET View State
If you still have any concerns or questions I will be glad to help.