469,958 Members | 1,976 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,958 developers. It's quick & easy.

Respond to "delete" events on dynamic controls

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
Nov 18 '05 #1
1 1232
Your post went unanswered. Have you resolved this issue?

--
Regards,
Alvin Bruney [ASP.NET MVP]
Got tidbits? Get it here...
http://tinyurl.com/3he3b
"Michael Ramey" <raterus@localhost> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

32 posts views Thread by Christopher Benson-Manica | last post: by
2 posts views Thread by Bob Tinsman | last post: by
5 posts views Thread by mkaushik | last post: by
19 posts views Thread by Daniel Pitts | last post: by
30 posts views Thread by Medvedev | last post: by
reply views Thread by rainxy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.