Reputation: 1
i am working on a project.but i have a problem.basically,i am using ajaxtoolkit tabcontainer.assume that i have 2 tabs which i created.let's call them tab1,tab2.in tab1 there is a button and textbox.when i click the button,i am writing some text into the textbox.then i am creating a tab dynamically.assume that it is called "tab3".the problem is when i click the button in the tab1,tab3 is diappearing.how can i prevent this?
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0" AutoPostBack="true"
Height="273px" Width="1050px">
<asp:TabPanel runat="server" HeaderText="tab1" ID="tab1">
<ContentTemplate>
tab2
here is where i am adding a new tab in the function:
AjaxControlToolkit.TabPanel tp = new AjaxControlToolkit.TabPanel();
tp.HeaderText = "tab3";
tp.ContentTemplate = Page.LoadTemplate("WebUserControl1.ascx");
tp.ID = "tab3";
TabContainer1.Tabs.Add(tp);
The html part is: part:blahblahblahblah
Upvotes: 0
Views: 1451
Reputation: 5381
When dealing with any dynamic controls, you will need to re-add them after every postback. My recommendation is to store your dynamically-added controls in the ViewState, and write a method that retrieves the information from ViewState and adds your tabs. Then call this method from Page_Init.
Upvotes: 1