0

I have a tab container with 5 tabs each having some charts inside them. I have set AutoPostBack = true and calling function to pouplate charts.

<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" AutoPostBack="true"  OnActiveTabChanged="Tab_changed" 
       CssClass="MyTabStyle">
<asp:TabPanel runat="server" HeaderText="Count" ID="TabPanel1" ><ContentTemplate>             
    <asp:UpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<asp:chart>
</asp:chart>

</ContentTemplate>                              
</asp:UpdatePanel>
</ContentTemplate>

 </asp:TabPanel>

protected void Tab_changed(object sender, EventArgs e)
{
    int index = TabContainer1.ActiveTabIndex;

        if (index == 0)
        {               
            count();
        }
        else if (index == 1)
        {

             created();


        }
}
public void tt_count()
{
  //code to populate charts
 }

When I am in tab1 (count), charts for tab1 get populated, when I switch to tab2 (created), charts for tab 2 are getting populated. Its working fine. What I am trying to do is if I switch to tab1 again, a page should not refresh again as its taking a long for charts to get populated again.

I.e. if one tab has populated once and we return to that tab again, it should not again refresh or repopulate the data..

user2486976
  • 97
  • 1
  • 1
  • 7
  • Set AutoPostBack to false(in the codebehind) when a panel is refreshed. – Tony Jan 28 '14 at 12:14
  • then it wont refresh new tab also, which hasn't been populated. – user2486976 Jan 28 '14 at 12:33
  • My bad misunderstood. Try storing the "visited" tab index in an array which could then be stored ViewState. Then in Tab_Changed check if the ActiveTabIndex is part of the if ViewState array if it is return, if not add and refresh. – Tony Jan 28 '14 at 13:48

0 Answers0