Multiple Button controls on form not firing Click event

There is probably a better way to do this, but here is what is going on. Imagine two "div" sections that contain images that have been tiled. One div contains all of the images that belong to a product, the other div contains the library of images you may want to assign to the product. Under each image in the library section is a Button control "Add". Under each image in the "Assigned to product" div there is a "Remove" Button control to remove it from the product. I'm trying to provide functionality where the user can simply click "Add" under the image they want to assign to a product, and "Remove" to pull an image from a product. I have two problems:

 1. The event that I have assigned to the images for "Add" and "Remove" is not firing.

2. How would I place data in each button to know which image id is getting either added or removed in the button OnClick event?

 Here is some of the code. I have munged it for simplicity:

// Loop to place all images and buttons on the form for Adding to the product.

while (

Button btnAddToPGroup = new Button();

btnAddToPGroup.Text = "Add";btnAddToPGroup.Click += new EventHandler(btnAddToPGroup_Click);



// OnClick Event 

void btnAddToPGroup_Click(object sender, EventArgs e)


     (Perform a database command here to add the image ID to the Product)


2/5/2008 5:03:07 AM 93655 articles. 6 followers. Follow

5 Replies

Similar Articles

[PageSpeed] 56
Get it on Google Play
Get it on Apple App Store

For a dynamic control to fire its event it need to be created in every postback. The code to populate the image button needs to run in every postback for your event to fire.


Please mark the answer if it helped you
2/5/2008 6:03:55 AM

I think you need to use any control like repeater for this type of functionlity.

It create dynamic images and also assign the image id to add button which you can get easily in command event of the repeater.


Shah Dharnendra G
Sr.Analyst Programmer,
2/5/2008 6:18:45 AM

Thanks for the suggestion. Is there a way to store the data manually in the Button control so it is accessible fromt the eventarg?

2/5/2008 4:26:40 PM

in button control, you have CommandArguement that you can use to store some info like personID or whateverID (int or string). you can get it back as follows:

string personID = ((Button)sender).CommandArguement;

2/5/2008 4:32:32 PM

Hi, refer following links 



Shah Dharnendra G
Sr.Analyst Programmer,
2/5/2008 5:28:12 PM

Similar Artilces:

How to fire events in other web form from other web form ?
Suppose that I have A and B web form. I want to trigger B web form's Page_Load event from A web form. How can I do that ? Thanks in advanced WilbertWilbert Bujn Create a public method in B that call the load method : public void Load(object sender, System.EventArgs e) { Page_Load(sender, e) ; } In the page_load of A, instanciate a B object and then call the function B myB = new B() ; myB.Load() ; Quicky Thank you quicky, it works fine. WilbertWilbert Bujn...

Urgent!!! Form inside Windows form control (that is embedded to Web page i.e aspx), not displayed on button click
 Hi all I have a Windows Form Control(i.e Windows Control Library), that consists of a Button "button1" and  a panel "panel1". Also I have a form "form1.cs". On form "form1.cs" I have a label whose text value i have set to  "Hi". On click of button "button1" on windows form control i am opening the form "form1.cs"  inside a panel and it displays "Hi". The code of windows form control is as below :  public partial class UserControl1 : UserControl    {    ...

An OnClick event doesn't fire up when a button is clicked in a Tab Panel in a Tab Container in an AJAX Web Form
Hello Post: I would like to enclose the following code so you can analize what is going on: "> " style="vertical-align:top;"> "> "> ...

superreview granted: [Bug 215928] onDblClick event handler IS fired on select multiple form element, WHEN clicking on scroll controls : [Attachment 131348] Proposed patch <> has granted Robert O'Callahan <>'s request for superreview: Bug 215928: onDblClick event handler IS fired on select multiple form element, WHEN clicking on scroll controls Attachment 131348: Proposed patch ------- Additional Comments from <> Fixing roc's + for him. ...

Web User Control - Button Click
I have a web user control which is has one Button control on it. It has a event for handling the click... if I put this user control ( button ) at the top  of the page, the click event does not get fired just page is refreshed...but where as if I move to the bottom of the page, ButtonClick is fired ???? I am completely clueless why is this change of behavior with respect to the position of the control?? Thanks. could you show us the code that you have problem with ...   Here is the code ( i have taken out the unwanted part of the page ) Please note that the bSave does ...

Modal form, modalResult button, OnKeyUp event fires on previous form
Tracking down a strange bug and so produced a simple test case: CallingForm Edit speedbutton CalledModalForm button, default=true, modalresult=mrOK edit.onKeyUp sets the caption to the IntToStr of the key speedbutton. onlclick creates, showsModal and releases the calledModalForm no code on calledModalForm Run, edit has focus press the speedbutton up comes calledModalForm press enter to close the edit on the calling form fires on the onkeyup...... Minor, but annoying. Is this what you guys would expect. I would have expected the calledModalForm to have consumed the ...

Web Form : Block the return button on the web form
Hello, I have a principal form with a list of information. From this form, I go on an edit forms and I want to control what is done on this form. For this, I want to block the button Windows back on my edit form. Somebody can help me ? Thank you for your help.  Jy. set the Session Variable (with your ID or whatever ) in the Principal Form when user click on Edit then put the One Back Button on your edit form and Redirect the page by using the Session variable value.Please Mark as Answred If This Blog has Helped You.RegardsMitesh Darjihttp://www.indianic.comhttp://www.mitatdotnet....

how to call controls of web control form in coding of other forms?
hello everyone i have one problem i have created one webcontrol shoppingcart in which there are two labels one of qty and other of amt which are initially enable =falsenow on other page(aspx page) i have one txtbox of qty as txtqty i want tat as soon as user enters qty txtqty and clicks on add cart button it shd be display d value in lblqty of web control shopping cart make sure i m using datalist on aspx page so give me suggestions on tat basis and my coding is in vb. plz give ur suggestions as fast as possible. Neeti what do you mean by webcontrol.... it this user control or normal ...

How to access a control on a web form from anoter web form
hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it possible to access lbl1 from form2, change its text permenantly? thanks.   refer: remember to click "Mark as Answer" on the post that helps you. MinaSamy: hi all I have this scenarios i have two web forms, one called form1 and the other called form2 form1 has a label with id "lbl1" is it p...

(web control button) click event doesn't fire
Hi, I've problem with simple case ... On my web page I have 2 user controls (one is logging control which has button and its onClick event works fine ... next control has also button and its onClick event doesn't fire) all handler are initialize correct and I've no idea why the next buttons (it happens to every next button that I try to insert on web page) bevave like don't have assemblied handlers :/ Anyone had problem like that ? Lukas         paste the code where the handler is getting hooked in the code behind file. It is in the section named Visual Studio gen...

Implementing .Net Form into an web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

.NET 1.1 Web Form
I am scratching my head trying to figure out why my events button (Lighting Bolt) is not displaying when I select buttons in Visual Studio 2003.  Has anybody had this happen before? I am tired into Visual Source Safe and wonder if that has anything to do with it?Moojjoo Õ¿Õ http://www.mmwebs.com Ummm>>>   That is the difference between C# and VB.NET.  VB.NET does not display the Lightning Bolt under properties in VS 2003.Moojjoo Õ¿Õ http://www.mmwebs.com

Multiple forms and form events [Edit]
I've run into a bit of a while creating a iOS app in Firemonkey (XE5). I have MainForm which creates a few other forms. The MainForm only has a tabcontrol and creates tabitems for any forms that I want to add. To do this, a layout on all child forms gets parented to each tabitem. One of the child forms has some edits that sometimes are hidden by the keyboard, so I decided it could use a scrollbox to always show any edit the user is modifying. To do that it looks like I need to monitor the child forms OnFocusChanged, OnVirtualKeyboardHidden/Shown events. The problem is, events for the...

when the user clicks the image button to show the calendar extender on my web form it submits the whole form instead of showing the calendar??
when the user clicks the image button to show the calendar extender on my web form it submits the whole form instead of just showing the calendar??  I have another button that submits the form. my calendar image button is acting like a submit button also instead of acting like a calendar popout button. Does anybody know how I can set an image button to not submit the form and cause my validations to render. I only want it to pop out the Ajax calendar for the specific textbox?   <ajaxToolkit:CalendarExtender runat="server" TargetControlID="txt...

Web resources about - Multiple Button controls on form not firing Click event -

Multiple sequence alignment - Wikipedia, the free encyclopedia
A multiple sequence alignment (MSA) is a sequence alignment of three or more biological sequences , generally protein , DNA , or RNA . In many ...

Sydney Trains missed multiple chances to avoid Edgecliff derailment, says ATSB report
... has highlighted concerns about a focus on a &quot;can-do culture&quot; rather than safety. Sydney Trains staff and senior managers missed multiple ...

Facebook Adds Multiple Matching Options for Custom Audiences
Facebook has added real-time matching across multiple data types to its custom audiences ad-targeting tool. The social network said in a Facebook ...

Multiple explosions kill at least seven near Baghdad
Multiple explosions kill at least seven near Baghdad

Meet the man who made "multiple six figures" in 5 days — playing daily fantasy sports
In the world of daily fantasy sports, there are two types of games: cash games and tournaments. Cash games can be head-to-head against one person, ...

Adult film star James Deen responds to multiple assault allegations
View image - The following story is not for readers under 18 James Deen is probably the most famous adult film star working ...

Multiple Victims In San Bernadino Mass Shooting; 1-3 Shooters Sought
When is it enough to actually do something? Fuck the NRA. Fuck the Republican party and the right wing hate machine. Those Syrian refugees might ...

The Philadelphia 76ers announced that they suspended Jahlil Okafor—he of the multiple fights outside
The Philadelphia 76ers announced that they suspended Jahlil Okafor—he of the multiple fights outside of bars and one of their only competent ...

Bluestacks now runs multiple Android apps on Windows simultaneously
Bluestacks has come a long way since its original app player in 2011, which was notable for being one of the first methods for running Android ...

Does China Mobile Ltd. (ADR) Have Any Gas After Forming This Multiple Bottom ...
Does China Mobile Ltd. (ADR) Have Any Gas After Forming This Multiple Bottom ... The stock of China Mobile Ltd. (ADR) ...

Resources last updated: 12/6/2015 11:38:05 AM