I'm trying to implement a call to a Javascript function that appears within a Gridview in each row. The code produces a button that can be clicked and brings up an Image Editor instance (Aviary by Adobe).
Because I don't have unique variable names then the same image is appearing each time, if I try to do this on a standalone page and change the Javascript variable names for each image the code works so I'm not sure what to do as I don't know how to make unique variable references.
I can't include the document.getElementByID parts inline as parameters to the function because I can't escape the single quotes.
The 3 javascript variables are
editImageControl editImageURL editImageFilename
<asp:TemplateField HeaderText="Edit Photo">
<ItemTemplate>
<asp:Image ID="editImage" runat="server" ImageUrl='<%# "http://images.foo.com/" & Eval("filename") %>' CssClass="noDisplay" />
<script>
var editImageControl = document.getElementById('<%# DirectCast(Container, GridViewRow).FindControl("editImage").ClientID%>');
var editImageURL = document.getElementById('<%# DirectCast(Container, GridViewRow).FindControl("editImage").ClientID%>').src;
var editImageFilename = '<%# Eval("filename") %>';
</script>
<!-- Add an edit button, passing the HTML id of the image and the public URL of the image -->
<p><input type='image' runat="server" src='http://images.aviary.com/images/edit-photo.png' value='Edit photo' onclick="return launchEditor(editImageControl, editImageURL, editImageFilename);" /></p>
</ItemTemplate>
</asp:TemplateField>