In this article we will see that how to create dynamic tabs.
For making dynamic tabs I will use Ajax Tab Container controls. I will create tabs dynamically, will add controls to each of the tabs dynamically and after that we will read the value of each control on some button click.
Step 1: Open visual studio and create a web site.

STEP 2: Add the refrence to AjaxToolkit.

STEP 3: Declare Globally TabContainer.

STEP 4: Next is we need to create tabs dynamically. We can write code for making Dynamic Tabs in Page_load event also but the problem of writing this code in Pageload event is: If we are creating dynamic tabs for a Sharepoint custom Webpart than it will throw error on postback events. But it will work for normal ASPX pages. For this reason I will write it in Page_Init function.


STEP 5: After creating dynamic tabs we will add dynamic controls to it. Here I will create one asp table and then add the controls to it and after adding controls I will add this dynamically generated table to the tabs of the Tab Container control.
The reason why I am adding a table is just for formatting. You can directly add controls to the panel.

STEP 6: Here I have added one button and created one click event on it. This button click event I will use for reading the dynamically generated controls

Here I used one placeholder PC1 also. If we are creating Dynamic tabs for ASP application than no problem but if we are building it for Sharepoint than it is very helpful. If we are not using it than sometimes postback triggers are showing some ajax javascript error.
Now press F5 and see the result.

Hope this article will be a help to you!

Arun CRPosted Nov 2, 2017, 7:33 AM
Hi Ravish,I'm using your code to create dynamic tabs, but as your code consists of old version of AjaxToolkit dll(i.e 3.0.3) and i are using 3.5.4 version, i am not able to create the tabs with this new version. But it will work smooth with old version as which you have used. I cannot use old version of ajax as it is having some dependencies in my code. So can you please help me to resolve this issue? If you have any idea please help me with that.
Anil GajeraPosted May 10, 2017, 3:09 AM
Thanks for solve dynamic tab with event
Gowtham RajamanickamPosted Mar 27, 2015, 9:39 AM
wellprepared articel..
Gowtham RajamanickamPosted Mar 27, 2015, 9:39 AM
good..
jessica vegaPosted Jan 7, 2014, 1:07 PM
how i can add event ActiveTabChanged from code???
SAI KRISHNA VELLANKIPosted May 3, 2013, 12:04 PM
Hi. Could you please tell me how to dynamically add Report Viewer Control to Tab Container? Thanks in advance
shahzad anjumPosted Feb 26, 2013, 1:51 AM
TabPanel is not working here. Any idea?
ajinkya DeeePosted Jul 25, 2012, 2:13 AM
What if i want the tabs vertical?? any solution plz
Ty BartonPosted Jan 20, 2012, 6:20 AM
Beware. If you add dynamic tabs to a tab container that is using vertical tabs you will get a Jscript error. I have yet to find a work around. If anyone knows of one please let me know on this current thread. http://forums.asp.net/t/1760620.aspx/1?Jscript+error+with+dynamic+tab+control
Kiran VaghelaPosted Sep 26, 2011, 6:22 AM
Dear Ravish, When page load first time then the control created but what if add dynamic one by one. We can add tabs at first time ti happen. but if we want to add control second time then it does not happen. Kiran Vaghela
SairamPosted Mar 16, 2011, 4:04 AM
Ur article is simple and easy to get to understand.can u provide article about how to create a Ajax page for creating greeting card
madhu soothananPosted Nov 30, 2010, 7:48 AM
how to create events for the dynamic tabs manually
IT ProfessionalPosted Aug 31, 2010, 2:28 PM
I am a VB.NET developer. I followed your article word to word but I am getting this error at PC1.Controls.Add(tbcDynamic)....Please help "Parameter cannot be Null: Parameter name-Child"
sri sai harshaPosted Aug 18, 2010, 3:10 AM
Thanks for providing this article.Can you let me know how to accomplish a similar solution related to the above one. I need to have tab container where data needs to be populated without postback. I have a dropdownlist in tab container which needs to be populated with values without postback..Can you help me out. Thanks, Harsha.
Former memberPosted Aug 2, 2010, 7:28 AM
Nice article