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

Creating an Event Handler for dymanically generated controls

Hi,

My last post was not worded correctly. What I really need to know is how
(what to type) to create an event handler for some ImageButtons that I
generate at run-time. I tried this:

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

Stop

End Sub

But the stop statement was not encountered after clicking on the
ImageButtons.

Thanks for any help,

Steve


Nov 18 '05 #1
3 1082

after the control has been generated in the code do

AddHandler CType(Page.FindControl("MyGeneratedControl"),
ImageButton).Click, ImageButton_Click

hth
-ashish


Steve Caliendo wrote:
Hi,

My last post was not worded correctly. What I really need to know is how
(what to type) to create an event handler for some ImageButtons that I
generate at run-time. I tried this:

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

Stop

End Sub

But the stop statement was not encountered after clicking on the
ImageButtons.

Thanks for any help,

Steve


Nov 18 '05 #2
Is this what you are after?

Private Sub ImageButton_Command(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.CommandEventArgs)
'do something
End Sub

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

Dim btn As ImageButton = new ImageButton
AddHandler btn.Command, AddressOf ImageButton_Command

End Sub

--Michael

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

My last post was not worded correctly. What I really need to know is how
(what to type) to create an event handler for some ImageButtons that I
generate at run-time. I tried this:

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

Stop

End Sub



But the stop statement was not encountered after clicking on the
ImageButtons.



Thanks for any help,



Steve





Nov 18 '05 #3
Yes, Thanks All !

Steve

"Raterus" <raterus@localhost> wrote in message
news:e6**************@TK2MSFTNGP10.phx.gbl...
Is this what you are after?

Private Sub ImageButton_Command(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.CommandEventArgs)
'do something
End Sub

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

Dim btn As ImageButton = new ImageButton
AddHandler btn.Command, AddressOf ImageButton_Command

End Sub

--Michael

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

My last post was not worded correctly. What I really need to know is how
(what to type) to create an event handler for some ImageButtons that I
generate at run-time. I tried this:

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

Stop

End Sub

But the stop statement was not encountered after clicking on the
ImageButtons.

Thanks for any help,

Steve


Nov 18 '05 #4

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

Similar topics

21
by: | last post by:
Hi, I am setting the NumericUpDown .Value property and the ValueChanged event is NOT being fired. Does this ONLY get fired when I change it on the UI and not programatically? Thanks
1
by: Don Hames | last post by:
I have created a window application in VS 2005 using C#. In the main form, I added a split container. I added controls to the left panel1 from the toolbox and they all work fine. I want to respond...
5
by: Dan | last post by:
Hi, I'd like to find out the control that caused a postback to be raised. Obviously this could simply done in a control event handler. I am not going to do this method and would like no...
3
by: Steve Caliendo | last post by:
Hi, My last post was not worded correctly. What I really need to know is how (what to type) to create an event handler for some ImageButtons that I generate at run-time. I tried this: ...
4
by: The Alchemist | last post by:
I am having a problem with a dynamically-generated Datagrid. It is important to point out that this problem does not exist with a design-time created Datagrid, but only with a dynamically generated...
2
by: Patrick | last post by:
I want to define a set of web-form templates in XML and render the equivalent web-form with ASP.NET, then process any input server controls on the form. Reading the XML file from Page_load is...
0
by: Matthew | last post by:
All, I have searched google and the newsgroups but can't find anything the same as what I am experiencing (though I may have missed something). I have controls (textboxes) within UserControls...
0
by: Mayur | last post by:
Hello all, Im trying to call my .net c# library functions from my unmanaged vc++(dialog based MFC) application . From that application i want add the event handler for the event generated in c#...
9
by: Tarscher | last post by:
hi all, I have this seemingly simple problem. I have lost a lot of time on it though. When a user selects a value from a dropdownlist (static control) a dynamic control is generated. I have...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
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
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
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.