Hello,everyone. I have a datalist control that shows a persons details such as his photo,name..etc. There is also an image button, which when clicked reveals a fileupload control. after i select the file to upload the image control should show the selected photo.
Now, i've already worked out the logic for showing the image. This works fine when i don't have the image inside the datalist. The problem i'm facing is my javascript does not identify the image id of the image that is inside the datalist. Following is my javascript code and the markup code...
function getRandomNumber()
{
var randNumber=Math.random(10000);
return randNumber;
}
function ClientUploadComplete(sender,args)
{
var handlerPage='<%= Page.ResolveClientUrl("~/Handlers/PreviewImageHandler.ashx") %>';
var queryString='?randomno='+getRandomNumber();
var src= handlerPage + queryString;
var clientID='<%= imgMember.ClientID %>';
document.getElementById(clientID).setAttribute("src",src);
}
<asp:DataList ID="dtlistEditMembers" runat="server" CssClass="dlistStyle">
<ItemTemplate>
<asp:Image ID="imgMember" ImageUrl='<%# "~/Handlers/GetImageHandler.ashx?B_ID=" + Eval("B_ID") %>' AlternateText="No Image" runat="server" />
..............
........
.......
<div class="EditFields">
<asp:Label ID="lblFullName" Text="Name:" runat="server"></asp:Label><asp:TextBox ID="txtFullName" Text='<%# Eval("Full_Name") %>'
</ItemTemplate>
</asp:DataList>
The underlined control is the image control whose client id, i want.When viewing the page's source...the asp:image....is converted to this
<img id="dtlistEditMembers_ctl00_imgMember" src="../../Handlers/GetImageHandler.ashx?B_ID=33" alt="No Image" style="border-width:0px;" />
so, how can i write the ClientUploadComplete function so that the variable
var clientID='<%= imgMember.ClientID %>';
actually recognize the imgMember Control???
Any Help would be apreciated.
Thanks, Minghang