473,406 Members | 2,352 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,406 software developers and data experts.

need help on how to detect which one of the dynamically loaded button fired the event

6
Hi guys! I am at my wits end detecting which one of the dymically loaded button fired the click event(since they all have same ID and text value)
Heres the scenario:

I have created a loop to read through the records of a table and creat dynamic buttons. I have also created the button_click event. But in the event handler I can not figure out at which point of the iteration the event was fired!!

my code is:
///////////// creating the button /////////////////////////
protected void Page_Load(object sender, EventArgs e)
{
while (reader.Read())
{
Panel panel= new Panel();
Table t= new Table();
TableCell c3 = new TableCell();
Button button1 = new Button();
button1.Text = "hide";
button1.Click += new EventHandler(button1_Click);
c3.Controls.Add(button1);

TableRow r = new TableRow();
r.Cells.Add(c3);
t.Rows.Add(r);
panel.Controls.Add(t);
}
}
/////////////// then in the event handler button1_click i need to figure out which one of the buttons fired this event, because by that I wish to figure out at which iteration of the loop the event-firing-button was created //////////////////////////

void button1_Click(object sender, EventArgs e)
{

}

any idea how to do that?i need to know it and i need it fast..!!
please help
thanx in advance!
Aug 2 '07 #1
3 1317
axxon
6
guys hellpp...!!gosh no body replied...!!
Aug 3 '07 #2
guys hellpp...!!gosh no body replied...!!

I have an idea, but i am not very sure of this, just give it a try.Each of the Buttons has a seperate ClientId. if u could store them while u create them then u could run a loop in the event handler to find out which button fired the event.

And one more thing if u can replace the Button with a RadioButton and place one Submit button i can give u the exact solution
Aug 3 '07 #3
jhardman
3,406 Expert 2GB
guys hellpp...!!gosh no body replied...!!
why did you post this in the asp forum? You aren't asking anything remotely related to asp. Some of us might be able to piece together a solution, but asp is a server-side technology. It does not relate in any way to client-side events and actions like button clicks.

Jared
Aug 3 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: RobG | last post by:
I am trying to dynamically add an onclick to an element, however I just can't get the syntax right. consider the following function: function doClick (evt,x) { // do things with evt and x } ...
1
by: Karl Seguin | last post by:
i have a dynamically created user control which contains a non-dynamically created ASP.Net button. When the button is clicked, the event is not fired. I know that the control must be created on...
5
by: MS Newsgroups | last post by:
Hi, I have a scenario where I am dynamically adding a control from code when a controls event is fired. The problem I have is that when the newly created control is clicked, the click event does...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
0
by: Dan | last post by:
hi, i have a page with two usercontrols: 1. a static menu control. 2. a dynamically loaded control as user interface the main page receives events from the menu and sets the apropriate ui...
4
by: Harry | last post by:
Hello, I have a page with a RadioButtonList and a PlaceHolder control. The RadioButtonList's AutoPostBack attribute is set to TRUE and its SelectedIndexChanged event loads one of three...
6
by: Steve Booth | last post by:
I have a web form with a button and a placeholder, the button adds a user control to the placeholder (and removes any existing controls). The user control contains a single button. I have done all...
1
by: jelle.huygen | last post by:
Hello, I have a problem in ASP.NET 2.0 with the viewstate of my dynamically added user control. I have reproduced the problem with a very simple user control and a very simple page. On my...
1
by: Christian Resma Helle | last post by:
Hey guys, I'm working on an AJAX Enabled ASP.NET Web application. I have a TreeView web control and an PlaceHolder web control. My PlaceHolder is inside an UpdatePanel and AsyncPostBacks are...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.