473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

generate tabs dynamically using ajax

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" %>
  2.  
  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" %>
  6.  
  7. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  8.  
  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>
  27.  
  28.         </cc1:TabContainer>
  29.         <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
  30.  
  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;
  5.  
  6.     protected void Page_Load(object sender, EventArgs e)
  7.     {
  8.  
  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 8285
acoder
16,027 Expert Mod 8TB
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.

Moderator
Nov 28 '08 #2
i do follow the rules from now.

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

Thank you

@acoder
Nov 28 '08 #3
acoder
16,027 Expert Mod 8TB
@ravindarjobs
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
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
acoder
16,027 Expert Mod 8TB
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

4
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...
12
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...
135
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...
5
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...
9
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...
1
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...
3
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...
7
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...
2
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. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...

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.