472,110 Members | 1,852 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,110 software developers and data experts.

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 1301
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

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.