Respond to "delete" events on dynamic controls

M

Michael Ramey

Hi,

I'm dynamically creating a table of "delete" imagebuttons, that correspond
to files on the webserver. I want to respond to clicks of these buttons, so
I know to know what file to delete. Here is the code I'm using

Dim imgShow As New ImageButton
imgShow.CommandName = "Delete"
imgShow.CommandArgument = arrayOfFiles(i)
AddHandler imgShow.Command, AddressOf Image_Command
'Then I proceed to add this button to a table, and loop again for each file

Public Sub Image_Command(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.CommandEventArgs)
If e.CommandName = "Delete" then
'do the delete code
End If
End Sub

This works great, but in order to use the AddHandler, the button must still
exist on the postback page. My problem, this is a delete button, so I don't
want to recreate the button. Does anyone have any ideas on how I can handle
this easily?

Thanks
--Michael
 

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

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,020
Latest member
GenesisGai

Latest Threads

Top