473,881 Members | 1,636 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

generate tabs dynamically using ajax

86 New Member
Hi friends, i am using ajax in asp.net.

i am using tab container, tab panel controls.

i want to add tab panel control dynamically on button click.

i form code is:

Expand|Select|Wrap|Line Numbers
  1. <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>
  3. <%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
  4.     Namespace="System.Web.UI" TagPrefix="asp" %>
  5. <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  9. <html xmlns="http://www.w3.org/1999/xhtml" >
  10. <head runat="server">
  11.     <title>Untitled Page</title>
  12. </head>
  13. <body>
  14.     <form id="form1" runat="server">
  15.     <div>
  16.         &nbsp;</div>
  17.       <asp:ScriptManager ID="ScriptManager1" runat="server">
  18.         </asp:ScriptManager>
  19.         <cc1:TabContainer ID="TabContainer1" runat="server" Width="600">
  20.             <cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="tab1">
  21.              <ContentTemplate>
  22.                     <asp:Button ID="asd" runat="server" Width="30" />
  23.                 </ContentTemplate>
  24.             </cc1:TabPanel>
  25.             <cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="tab2">
  26.             </cc1:TabPanel>
  28.         </cc1:TabContainer>
  29.         <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
  31.     </form>
  32. </body>
  33. </html>

my page code is:

Expand|Select|Wrap|Line Numbers
  1. public partial class _Default : System.Web.UI.Page 
  2. {
  3.     int i = 0;
  4.     AjaxControlToolkit.TabPanel tp;
  6.     protected void Page_Load(object sender, EventArgs e)
  7.     {
  9.     }
  10.     protected void Button1_Click(object sender, EventArgs e)
  11.     {
  12.         i = i + 1;
  13.         tp = new AjaxControlToolkit.TabPanel();
  14.         tp.ID = "tp" + i.ToString();
  15.         Button b = new Button();
  16.         b.ID = "b" + i.ToString();
  17.         tp.Controls.Add(b);
  18.         tp.HeaderText = "i am new" + i.ToString();
  19.         TabContainer1.Controls.Add(tp);
  20.     }
  21. }

i am able to add one dynamic tab when i click the button first time. But when i click the button for the second time, i am getting error.

"Specified argument was out of the range of valid values.
Parameter name: index "

any help?

thank you.
Nov 28 '08 #1
5 8351
16,027 Recognized Expert Moderator MVP
As a full member now, you should know that we expect your code to be posted in [code] tags (See How to Ask a Question).

This makes it easier for our Experts to read and understand it. Failing to do so creates extra work for the moderators, thus wasting resources, otherwise available to answer the members' questions.

You have been told nicely before, but the advice has fallen on deaf ears it seems. Regard this as a warning. Further violations may lead to a temporary an your account which I'm sure you'll want to avoid.

Please use the tags in future.

Nov 28 '08 #2
86 New Member
i do follow the rules from now.

Indeed, yes i forgotten to add them.
i wont repeat it again.

Thank you

Nov 28 '08 #3
16,027 Recognized Expert Moderator MVP
That doesn't seem like a JavaScript error. It seems like a .NET one. Can you post the client-side version of your code.
Nov 28 '08 #4
86 New Member
yes it is .net using ajax.

this link has helped me

Siderite Zackwehdex's Blog: Fixing TabContainer to work with dynamic TabPanels
Nov 28 '08 #5
16,027 Recognized Expert Moderator MVP
Glad you got it working and thanks for posting the solution :)
Nov 28 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

by: k.mitz | last post by:
Hi, I have a PHP application that allows users to generate a .pdf report of their database content. Normally, I've had to refresh a page to call the script to generate the report, so there's a second or so when the browser goes blank. I was wondering if it was possible to use AJAX to call the script to generate the report, then begin the download without refreshing the page (or in the case of I.E., leaving me with a blank window that...
by: nat | last post by:
Hi all, I was going to post this in the AJAX forum, but apparently someone posted an AJAX/C# question in there today and was told to try this forum instead. So here goes: I'm trying to figure out whether AJAX will work with dynamically created controls in C#.NET. I have been able to get non-dynamically created controls to work, but so far none of my dynamic controls or events linked to them are able to work with AJAX. Does anyone know...
by: Xah Lee | last post by:
Tabs versus Spaces in Source Code Xah Lee, 2006-05-13 In coding a computer program, there's often the choices of tabs or spaces for code indentation. There is a large amount of confusion about which is better. It has become what's known as “religious war” — a heated fight over trivia. In this essay, i like to explain what is the situation behind it, and which is proper.
by: sean.gilbertson | last post by:
Hi, I'm sort of new to ASP.NET 2.0 and ASP.NET in general. I have some data that I would like to display in a tabular format, but I'm going to be generating the columns dynamically, and I would like to make it so that each row can be expanded downward dynamically to show detailed information. So far, it seems like I'll have to use an asp:Table and generate the entire thing in code -- including the Javascript to hide and show the
by: pbd22 | last post by:
Hi. I am building a bit of a "learn-as-you-go" web site. I have tabs that change based on what page the user is on. The problem is, I have been using a javascript doOnLoad function to recognize the page the user is on and, then, provide the correct tabs. This depends on a normal URL, such as http://www.mysite.com/index.html. But, as I build the site, I am learning that there are times when all
by: jianxin9 | last post by:
Hi, I have an ajax powered tabs box that has a javascript drop-down search menu in the first tab. When I click on another tab, and go back to the first tab I have to refresh the page to get the information to load. Any suggestions on how I might get around that. The articles tab is the tab where the javascript won't load. Thanks so much for any help you might be able to provide: This is what the tabs code looks like: <ul...
by: samikrc | last post by:
Hello, I have an accordion (using the Rico framework at www.openrico.org) and each tab of the accordion is basically some sort of wizard (having a description and a 'Start' button in each tab). When the Start button is pressed, I get the contents of only that tab updated. I am using the innerHTML property of the div placeholder to update the contents, and the HTML is provided from a perl script on the server side. The page layout looks...
by: Nathan Sokalski | last post by:
I have a page which I dynamically add several usercontrols (*.ascx files) to using the following code: Public Sub Refresh() For Each section As DataRow In Me.GetSections().Rows CType(Me.FindControl("admin" & CStr(section("buttontext")).Replace(" ", "")), adminsection2).RefreshSection() Next End Sub
by: =?Utf-8?B?aUhhdkFRdWVzdGlvbg==?= | last post by:
I have a dropdown with the list of items from 1 to 6 Below the dropdown there is a table(This table contains all textbox and dropdownlist) with 6 rows and 5 cloums, which is INVISIBLE by default. if I select 3 from the drop down, I should get the table with the 3 rows and 5 cloums , turn visible with all the controls in it. OR if I select 4 from the drop down, I should get the table with the 4 rows and 4 cloums, turn visible with all the...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.