473,479 Members | 2,117 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Dynamic Events Question

Below is the code I'm using. It works as designed but now I want to
determine which of the ten buttons was clicked. Any help on how to do this
is appreciated.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim x As Int16

For x = 1 To 10

Dim btnAdd As New Button

btnAdd.ID = x.ToString

Page.FindControl("FORM1").Controls.Add(btnAdd)

btnAdd.Text = "Click Me"

AddHandler btnAdd.Click, AddressOf btnAdd_Click

Next

End Sub

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Response.Write("hello world")

End Sub


Nov 18 '05 #1
1 813
Don't you hate it when you look for hours and just after asking you figure
it out... :-)

Here is what I did and it worked.

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Dim myButton As Button

myButton = CType(sender, Button)

Response.Write(myButton.ID)

End Sub

"Bishop" <Bi****@Spam.com> wrote in message
news:eL**************@TK2MSFTNGP12.phx.gbl...
Below is the code I'm using. It works as designed but now I want to
determine which of the ten buttons was clicked. Any help on how to do
this is appreciated.

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim x As Int16

For x = 1 To 10

Dim btnAdd As New Button

btnAdd.ID = x.ToString

Page.FindControl("FORM1").Controls.Add(btnAdd)

btnAdd.Text = "Click Me"

AddHandler btnAdd.Click, AddressOf btnAdd_Click

Next

End Sub

Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs)

Response.Write("hello world")

End Sub


Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
6793
by: MikeY | last post by:
Hi Everyone, I am working in C#, windows forms.My question is this. All my button dynamic controls properties are present and accounted for except for the"FlatStyle" properties. I can't seem to...
0
864
by: Mustafa Rabie | last post by:
Hi All, I have some questions for things that i couldn't get around. if someone can help i'd really appreciate it. 1) I want to have a list in my applications that are populated by my...
2
4213
by: Michael Ramey | last post by:
Howdy, I think I have a good question! I'm creating a usercontrol, and within this usercontrol, I'm dynamically creating controls (imagebuttons to be exact), that the user can click on which...
13
3642
by: Chris Thunell | last post by:
I have created several grids dynamically and have added them to different HTML placeholders on a vb.net web form. The grids and controls within them come up and view beautifully when the web page...
4
6709
by: Chuck Ritzke | last post by:
Hi, I've searched the newsgroup and other sources to understand how to handle runtime controls and see I'm not the only one who's confused, but I'm still not quite sure of the best way to handle...
3
3943
by: Leo J. Hart IV | last post by:
OK, here's another question for the experts: I am building a multi-step (3 steps actually) form using a panel for each step and hiding/displaying the appropriate panel/panels depending on which...
2
1349
by: Jörn von Holten | last post by:
Hi, my 3-tier system has a separate bizz-logic and storage service (MVC paradigm as usual) and the bizz-logic layer shall drive the logic (workflow) of the ASP site. My "idea" is (alike Xaml...
2
3178
by: Linda | last post by:
Hey all, I'm not too sure if this is the right place to post my question - or if I should go to a JSP group. Anyway here is my question. I am looking at finding/ making an online dynamic...
1
6048
by: Kenneth Siewers Møller | last post by:
Hi there I have a question about dynamic event binding. I have a class called Fraction in which a number of events are declared. Some of the events are: OnNameChanged OnCostChanged...
0
7033
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
6903
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
7071
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5318
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
4468
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2974
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1291
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
557
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
170
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.