i added two dynamic button in ASP.NET
1.ADD
2.REMOVE
i want to remove ADD button on click of REMOVE Button in ASP.NET
crish as sou given me javascript function but how I will call it on a remove button....please give me idea
How to remove one dynamic added button on click of a another dynamic button
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Ibrahim ErsoyRank #106 · 20.6K reputationPosted Jun 8, 2010, 2:16 AM EDT
Add two variables below class definition:
dynamic dt = new Button();
dynamic dt2 = new Button();
And update your code as seen below:
protected void Page_Load(object sender, EventArgs e)
{
dt.Text = "Add";
dt2.Text = "Remove";
form1.Controls.Add(dt);
form1.Controls.Add(dt2);
dt.Click += new EventHandler(Add_Button);
dt2.Click += new EventHandler(Remove_Button);
}
public void Add_Button(Object sender, EventArgs e)
{
//Do Something
}
public void Remove_Button(Object sender, EventArgs e)
{
form1.Controls.Remove(dt);
}
I have uploaded the source code,too...Hope it helps!
Cheers,
CrishRank #1,487 · 1.1K reputationPosted Jun 8, 2010, 2:17 AM EDT
try below code..
function DeleteOptionButton(icounter)
{
//debugger;
txtinput.removeChild(document.getElementById('btndel'+icounter));
document.getElementById('<%=hdnProductCounter.ClientID %>').value = eval(document.getElementById('<%=hdnProductCounter.ClientID %>').value)-1;
}
thanks
Don't forget to Mark Do you like this Answer
that solved your problem!