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:
my page code is:
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.
i am using tab container, tab panel controls.
i want to add tab panel control dynamically on button click.
i form code is:
Code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="System.Web.UI" TagPrefix="asp" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<cc1:TabContainer ID="TabContainer1" runat="server" Width="600">
<cc1:TabPanel ID="TabPanel1" runat="server" HeaderText="tab1">
<ContentTemplate>
<asp:Button ID="asd" runat="server" Width="30" />
</ContentTemplate>
</cc1:TabPanel>
<cc1:TabPanel ID="TabPanel2" runat="server" HeaderText="tab2">
</cc1:TabPanel>
</cc1:TabContainer>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
</form>
</body>
</html>
my page code is:
Code:
public partial class _Default : System.Web.UI.Page
{
int i = 0;
AjaxControlToolkit.TabPanel tp;
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
i = i + 1;
tp = new AjaxControlToolkit.TabPanel();
tp.ID = "tp" + i.ToString();
Button b = new Button();
b.ID = "b" + i.ToString();
tp.Controls.Add(b);
tp.HeaderText = "i am new" + i.ToString();
TabContainer1.Controls.Add(tp);
}
}
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.
Comment