473,663 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1794
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*******@epio n.com> wrote in message
news:#w******** ******@TK2MSFTN GP10.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_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s)

stop

end sub

Do you know what I'm doing wrong ?

Steve
"Kevin Spencer" <ks******@takem pis.com> wrote in message
news:%2******** *******@tk2msft ngp13.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*******@epio n.com> wrote in message
news:#w******** ******@TK2MSFTN GP10.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.EventArg s) Handles MyBase.Load
Dim imgbtn As New ImageButton
imgbtn.ID = "myimagebtn "
imgbtn.ForeColo r = System.Drawing. Color.Azure
imgbtn.Visible = True
form1.Controls. Add(imgbtn)

AddHandler CType(Page.Find Control("myimag ebtn"),
ImageButton).Cl ick, AddressOf ImageButtonClic k
End Sub

Private Sub ImageButtonClic k(ByVal sender As Object, ByVal e As
ImageClickEvent Args)

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_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s)

stop

end sub

Do you know what I'm doing wrong ?

Steve
"Kevin Spencer" <ks******@takem pis.com> wrote in message
news:%2******** *******@tk2msft ngp13.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*******@epio n.com> wrote in message
news:#w****** ********@TK2MSF TNGP10.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_Cli ck

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

"Steve Caliendo" <sc*******@epio n.com> wrote in message
news:#N******** ******@tk2msftn gp13.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_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s)

stop

end sub

Do you know what I'm doing wrong ?

Steve
"Kevin Spencer" <ks******@takem pis.com> wrote in message
news:%2******** *******@tk2msft ngp13.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*******@epio n.com> wrote in message
news:#w******** ******@TK2MSFTN GP10.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******@takem pis.com> wrote in message
news:ed******** ******@TK2MSFTN GP10.phx.gbl...
You have to wire up the Event Handler to the object's event, using An
AddHandler statement. Example:

AddHandler Button1.Click, ImageButton_Cli ck

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

"Steve Caliendo" <sc*******@epio n.com> wrote in message
news:#N******** ******@tk2msftn gp13.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_Cli ck(ByVal sender As System.Object, ByVal e As
System.EventArg s)

stop

end sub

Do you know what I'm doing wrong ?

Steve
"Kevin Spencer" <ks******@takem pis.com> wrote in message
news:%2******** *******@tk2msft ngp13.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*******@epio n.com> wrote in message
news:#w******** ******@TK2MSFTN GP10.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*********@bo wne.com> wrote in message
news:uD******** ******@TK2MSFTN GP09.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******@takem pis.com> wrote in message
news:ed******** ******@TK2MSFTN GP10.phx.gbl...
You have to wire up the Event Handler to the object's event, using An
AddHandler statement. Example:

AddHandler Button1.Click, ImageButton_Cli ck

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

"Steve Caliendo" <sc*******@epio n.com> wrote in message
news:#N******** ******@tk2msftn gp13.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_Cli ck(ByVal sender As System.Object, ByVal e As System.EventArg s)

stop

end sub

Do you know what I'm doing wrong ?

Steve
"Kevin Spencer" <ks******@takem pis.com> wrote in message
news:%2******** *******@tk2msft ngp13.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*******@epio n.com> wrote in message
> news:#w******** ******@TK2MSFTN GP10.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

0
1319
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 have set 'AutoGenerateColumns' property as false. I am raising few events from the Template controls e.g Text Chamged event of TextBox UI control, and bubbling the same event to the Parent control using 'RaiseBubbleEvent' method of Control class. I...
6
1203
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 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,
1
1357
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 delete event fires the place holder is cleared and repopulated. Unfortunatly the UniqueID carries on increaseing from the last UniqueID of the cleared controls. This meens if a button is clicked and page is posted when the page is rebuild the...
9
2325
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 into the place holder. This is done dynamically based on the choice they selected. This user control has a datagrid in it that supports paging. When I click on the next or prev buttons of the datagrid in a user control it should display the next page...
9
14442
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 does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same time. I have to click twice on the controls for the events to be raised, the first time nothing...
2
2704
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 1 2 3 4 5 ... Next Last >> I have achieved the first/previous/next/last buttons quite easily as follows in the ASPX (1.1) page:
2
1344
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 event created of dyanamically created button. Please help me, if any one having solution for my problem. I know that i can raise that event if i recreate these controls on page load but my reqirements doesn't allow me to do so. My code for...
1
4651
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 ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by pressing Remove button the selecetd row will be removed. I used viewstate to keep my value for postback, I want by changing selectedvalue of...
0
3492
by: MaryamSh | last post by:
Create Dynamic Dropdownlist Controls and related event -------------------------------------------------------------------------------- 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 ,another row will be created with the same control (I mean another dropdown and 2 button) and so on. and by...
0
8858
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8771
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8548
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7371
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6186
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5657
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4182
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4349
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2763
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 we have to send another system

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.