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

Trapping Click/Command Event for run time image buttons

I have the code snippet below. I fill a table of imagebuttons and would
like to know which one was clicked to trigger the post back. Unfortunately,
the Command event does not fire unless I load the images on the load_page
event. Since I want to load the table of images based on the click event
from another control, and only based on feedback from some controls do I
even display the image list, I thought I could trap the command or click
event, but I can not.

Any ideas? Thanks in advance.

Protected WithEvents img As System.Web.UI.WebControls.ImageButton

Public Sub GoItem(ByVal sender As System.Object, ByVal e As
System.Web.UI.WebControls.CommandEventArgs) Handles img.Command

Response.Write("<script language=javascript>window.alert('Image1 was
commanded with commandarg = " & sender.CommandArgument & "')</script>")

End Sub

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

'Put user code to initialize the page here

' IF I LOAD IT HERE IT WORKS OF COURS - FillImages(10, 0)

End Sub

Private Sub btnFillTable_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnFillTable.Click

' ----------------- HERE ID DOES NOT

FillImages(10, 100)

End Sub

Public Sub FillImages(ByVal image_count As Integer, ByVal start_value As
Integer)

Dim tr As System.Web.UI.WebControls.TableRow

Dim td As System.Web.UI.WebControls.TableCell

Dim img As New System.Web.UI.WebControls.ImageButton

Dim i As Integer

Table1.Rows.Clear()

For i = 1 To 10

tr = New System.Web.UI.WebControls.TableRow

td = New System.Web.UI.WebControls.TableCell

img = New ImageButton

img.ID = "img" & "_" & i.ToString()

img.ImageUrl = "images/small_note.gif"

img.CommandName = "Contact" & i

img.CommandArgument = i + start_value

AddHandler img.Command, AddressOf GoItem

img.EnableViewState = False

td.Controls.Add(img)

tr.Cells.Add(td)

Table1.Rows.Add(tr)

Next

End Sub

'End Sub


Jul 19 '05 #1
0 2227

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

Similar topics

4
by: Wugi | last post by:
I'm trying to find an equivalent of key-event trapping which is easy in QBasic. Several of my programs build up a geometric figure with two parameter line families, eg with two nested for..next...
3
by: Paul | last post by:
I have an Access 2000 database with a form that is giving me some major headaches. When you open the form, it displays all records and allows editing, but has AllowAdditions set to False so that...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
3
by: windandwaves | last post by:
Hi Gurus Does anyone know how I set the error trapping to option 2 in visual basic. I know that you can go to tools, options and then choose on unhandled errors only, but is there a VB command...
4
by: Keith | last post by:
I have the following code in the On No Data event of a report: **** On Error GoTo err_trap MsgBox "No items matching criteria.", vbInformation, gcApplication Cancel = True err_trap: If...
7
by: Neil | last post by:
I have a check box on a form that's bound to a function that returns a True/False value. When the user clicks on the check box, I run some code through the MouseDown event. Everything works fine. ...
0
by: Jim Mitchell | last post by:
I have the code snippet below. I fill a table of imagebuttons and would like to know which one was clicked to trigger the post back. Unfortunately, the Command event does not fire unless I load...
5
by: mayur_hirpara | last post by:
Hi, I have been developing web applications for a while now. However, as I was thinking through the architecture I really don't understand the "How server can identify between which buttons has...
3
by: Andreas Wöckl | last post by:
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...
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:
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...
0
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...
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...

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.