Have you checked the UniqueID
property?
http://msdn.microsoft.com/en-us/library/vstudio/system.web.ui.control.uniqueid(v=vs.100).aspx
How can I get the ID of ImageButton for javascript, if the ImageButton was created in code behind?
-
24-06-2023 - |
Question
I created an ImageButton in code buhind-
var img = new ImageButton();
img.ID = "Del" + i.ToString();
img.ImageUrl = "images/1395958363_meanicons_57.png";
img.Width = 48;
img.Height = 38;
img.OnClientClick = "javascript:void(DeleteBook())";
Label1.Controls.Add(img);
Now I need to get the ID of the ImageButton. Can anyone help me with this?
P.S The ImageButton was creates in "for", so I don't know how mutch ImageButton I have and what is them ID
Solution
OTHER TIPS
you can pass the img.ID into the javascript DeleteBook() function directly.
or better yet you can pass this directly eg: OnClientClick ="DeleteBook(this)"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow