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
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
CrishPosted Jun 8, 2010, 6:17 AM
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!
Ibrahim ErsoyPosted Jun 8, 2010, 6:16 AM
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,