473,386 Members | 1,801 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,386 software developers and data experts.

Event handling of dynamic controls

Hi,

I'm creating 5 ImageButton controls in the panel control, and I have a
unique ID specified for each one.

When I click on any one of them, the Page_Load executes (Of course), but how
do I know which ImageButton caused the post back ? Does it get handled in
the Page_Load or do I need to create a new event handler ?

Thanks,

Steve
Nov 18 '05 #1
6 1194
If I understand you correctly, you would want to create an Event Handler. I
am just not sure what you meant by a "new" Event Handler.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Steve Caliendo" <sc*******@epion.com> wrote in message
news:#w**************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm creating 5 ImageButton controls in the panel control, and I have a
unique ID specified for each one.

When I click on any one of them, the Page_Load executes (Of course), but how do I know which ImageButton caused the post back ? Does it get handled in
the Page_Load or do I need to create a new event handler ?

Thanks,

Steve

Nov 18 '05 #2
Ok, I tried adding this event handler and it doesn't fire when I click one
of the image buttons.

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

stop

end sub

Do you know what I'm doing wrong ?

Steve
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
If I understand you correctly, you would want to create an Event Handler. I am just not sure what you meant by a "new" Event Handler.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Steve Caliendo" <sc*******@epion.com> wrote in message
news:#w**************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm creating 5 ImageButton controls in the panel control, and I have a
unique ID specified for each one.

When I click on any one of them, the Page_Load executes (Of course), but

how
do I know which ImageButton caused the post back ? Does it get handled in the Page_Load or do I need to create a new event handler ?

Thanks,

Steve


Nov 18 '05 #3
ok this works for me

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim imgbtn As New ImageButton
imgbtn.ID = "myimagebtn"
imgbtn.ForeColor = System.Drawing.Color.Azure
imgbtn.Visible = True
form1.Controls.Add(imgbtn)

AddHandler CType(Page.FindControl("myimagebtn"),
ImageButton).Click, AddressOf ImageButtonClick
End Sub

Private Sub ImageButtonClick(ByVal sender As Object, ByVal e As
ImageClickEventArgs)

End Sub
hth
-ashish

Steve Caliendo wrote:
Ok, I tried adding this event handler and it doesn't fire when I click one
of the image buttons.

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

stop

end sub

Do you know what I'm doing wrong ?

Steve
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
If I understand you correctly, you would want to create an Event Handler.


I
am just not sure what you meant by a "new" Event Handler.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Steve Caliendo" <sc*******@epion.com> wrote in message
news:#w**************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm creating 5 ImageButton controls in the panel control, and I have a
unique ID specified for each one.

When I click on any one of them, the Page_Load executes (Of course), but


how
do I know which ImageButton caused the post back ? Does it get handled
in
the Page_Load or do I need to create a new event handler ?

Thanks,

Steve



Nov 18 '05 #4
You have to wire up the Event Handler to the object's event, using An
AddHandler statement. Example:

AddHandler Button1.Click, ImageButton_Click

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Steve Caliendo" <sc*******@epion.com> wrote in message
news:#N**************@tk2msftngp13.phx.gbl...
Ok, I tried adding this event handler and it doesn't fire when I click one
of the image buttons.

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

stop

end sub

Do you know what I'm doing wrong ?

Steve
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
If I understand you correctly, you would want to create an Event Handler.
I
am just not sure what you meant by a "new" Event Handler.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Steve Caliendo" <sc*******@epion.com> wrote in message
news:#w**************@TK2MSFTNGP10.phx.gbl...
Hi,

I'm creating 5 ImageButton controls in the panel control, and I have a
unique ID specified for each one.

When I click on any one of them, the Page_Load executes (Of course),
but how
do I know which ImageButton caused the post back ? Does it get
handled in the Page_Load or do I need to create a new event handler ?

Thanks,

Steve



Nov 18 '05 #5
Hey guys,

but what about child controls? I am having the same problem. I created a web
custom control that will basically draw a table with some controls inside.
One of those controls is a command button. I can't get the Onclick event of
this command button to fire. How does it work for child controls?

Thanks!

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
You have to wire up the Event Handler to the object's event, using An
AddHandler statement. Example:

AddHandler Button1.Click, ImageButton_Click

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Steve Caliendo" <sc*******@epion.com> wrote in message
news:#N**************@tk2msftngp13.phx.gbl...
Ok, I tried adding this event handler and it doesn't fire when I click one
of the image buttons.

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

stop

end sub

Do you know what I'm doing wrong ?

Steve
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
If I understand you correctly, you would want to create an Event

Handler.
I
am just not sure what you meant by a "new" Event Handler.

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Steve Caliendo" <sc*******@epion.com> wrote in message
news:#w**************@TK2MSFTNGP10.phx.gbl...
> Hi,
>
> I'm creating 5 ImageButton controls in the panel control, and I have a > unique ID specified for each one.
>
> When I click on any one of them, the Page_Load executes (Of course),

but how
> do I know which ImageButton caused the post back ? Does it get

handled
in
> the Page_Load or do I need to create a new event handler ?
>
> Thanks,
>
> Steve
>
>



Nov 18 '05 #6
Hi Juan,

Well, you're talking about a somewhat different scenario here, as the
original question was about handling the events fired by dynamically-added
Controls in an ASPX Page. However, there are some similarities (a Page is a
Control, and the child Controls of a Page are just that: Child Controls). In
any case, the basic principle is the same. In the case of a Page with
dynamically-added Child Controls, you have to wire up an event handler in
the Page to handle the event fired by the Child Control. In a custom Server
Control, you must do essentially the same thing. The following .Net SDK
article should be helpful:

http://msdn.microsoft.com/library/en...asp?frame=true

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Juan Romero" <ju*********@bowne.com> wrote in message
news:uD**************@TK2MSFTNGP09.phx.gbl...
Hey guys,

but what about child controls? I am having the same problem. I created a web custom control that will basically draw a table with some controls inside.
One of those controls is a command button. I can't get the Onclick event of this command button to fire. How does it work for child controls?

Thanks!

"Kevin Spencer" <ks******@takempis.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
You have to wire up the Event Handler to the object's event, using An
AddHandler statement. Example:

AddHandler Button1.Click, ImageButton_Click

--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Big things are made up
of lots of little things.

"Steve Caliendo" <sc*******@epion.com> wrote in message
news:#N**************@tk2msftngp13.phx.gbl...
Ok, I tried adding this event handler and it doesn't fire when I click one of the image buttons.

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

stop

end sub

Do you know what I'm doing wrong ?

Steve
"Kevin Spencer" <ks******@takempis.com> wrote in message
news:%2***************@tk2msftngp13.phx.gbl...
> If I understand you correctly, you would want to create an Event Handler.
I
> am just not sure what you meant by a "new" Event Handler.
>
> --
> HTH,
> Kevin Spencer
> .Net Developer
> Microsoft MVP
> Big things are made up
> of lots of little things.
>
> "Steve Caliendo" <sc*******@epion.com> wrote in message
> news:#w**************@TK2MSFTNGP10.phx.gbl...
> > Hi,
> >
> > I'm creating 5 ImageButton controls in the panel control, and I
have a > > unique ID specified for each one.
> >
> > When I click on any one of them, the Page_Load executes (Of
course), but
> how
> > do I know which ImageButton caused the post back ? Does it get

handled
in
> > the Page_Load or do I need to create a new event handler ?
> >
> > Thanks,
> >
> > Steve
> >
> >
>
>



Nov 18 '05 #7

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

Similar topics

8
by: Ashish Shridharan | last post by:
Hi All I have been trying to add a control to the header cell of a datagrid on my ASP.NET page. These controls are defined in the HTML as ASP.NET web controls. They are being added into the...
0
by: Makarand | last post by:
Hi Friends I am having problem in Event handling in ASP.NET. Let me tell you what I am doing, I have having DataGrid for which I am using 'Dynamic addition of Template controls'. For this I...
6
by: Steve Caliendo | last post by:
Hi, I'm creating 5 ImageButton controls in the panel control, and I have a unique ID specified for each one. When I click on any one of them, the Page_Load executes (Of course), but how do I...
1
by: Paul Johnson | last post by:
I have problems with eventhandlers when dynamically moving controls in ASP.NET. The controls are loaded into a placeholder on postback so that the eventhadlers can fire. If a move evet or...
9
by: Sridhar | last post by:
Hi, I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control...
9
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it...
2
by: WolfyUK | last post by:
Hello, I have a standard asp:DataGrid called CasesGrid that I wish to write my own paging controls for. The aim is to get something like the following rendered to screen: << First < Previous...
2
by: Hellogeetu | last post by:
Hi All, I am creating dynamic controls but not on page_load event but on one of the button click event. I m able to get the controls value by using request.form but i m unable to handle the...
1
by: MaryamSh | last post by:
Hi, I am creating a Dynamic Search in my application. I create a user control and in Page_load event I create a dynamic dropdownlist and 2 dynamic button (Add,Remove) By pressing Add button...
0
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- Hi, I am creating a Dynamic Search in my application. I...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.