capture click event of multiple image buttons

A

Andreas Wöckl

HI Group!

I have to programmatically create a user input form with various Checkbox
and RadioButton lists - Beside every List I have to place an image button
that is able to reset the checkboxlists and radiobutton lists.

if i declare a variable with

private withEvents img as ImageButton

and have a sub with..

Protected Sub Click1(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) _

Handles img.Click

msgbox("test")

End Sub

My Code for examle iterates 2 times but only one event is captured. So how
can I assure that every event of my buttons (could be 20 or more) is
captured. I would need to reset the value of specific controls with that
code!

Many thanks in advance!

best regards

andy
 
C

Cowboy \(Gregory A. Beamer\)

If I read you correctly, you are attempting to set radiobuttons or
checkboxlist items with image buttons, giving the user two ways to set the
selected value(s). If so, let's forget the radiobuttonlist for a moment, as
only one radio button can be checked at any one time, making it the easier
problem to solve.

You can wire all buttons to the same click event. I do not know the VB
syntax to have multiple controls hit the same event, but it is the addition
of a simple delegate assingment in C#. You can easily do this dynamically,
so the buttons will be wired without having to know how many there are. You
then determine which button sets which checkbox, but this is done as you
render the list, so it is not difficult.

When a button is clicked, you call a separate routine that runs through all
of the checkboxes and determines which are checked and which are not. Make
it a separate routine, for reuse. You will call the same routine when you
submit the form, for example.

Hope this helps.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
 
A

Andreas Wöckl

HI Gregory!

Unfortunately I am a beginner in developing .Net. Do you have some Code for
me to wire all buttons to the same click event? Do I have to define a
variable like

protected withEvents img ImageButton

at the beginning of the class?

My goal is to RESET the values of checkbox or radiobutton lists - not to
set -just to put away the values!

best regards

andy
 
C

Cowboy \(Gregory A. Beamer\)

VB.NET or C#?

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

*********************************************
Think outside the box!
*********************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top