How to display Image Description?
-
:(I have a repeater control to display thumbnail pictures. The itemtemplate is made of html image control. When user clicks on the thumbnail picture, I want it to display a larger image and display the image description in a label( the image description is saved in database). The large image is also a html control. My current code is : I have a getPhoto function which will get the thumbnail pictures through IhttpHandler and bound to the repeater control. Then I have a repPhotoG_ItemDataBound function, here I add the javascript to the image html control and call a javascript to pass the thumbnail imagename as parameter and show the large image. All this works fine, but I just don’t know how to get and display the image description. Please help!! private void repPhotoG_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { //finding repeater item Image System.Web.UI.HtmlControls.HtmlImage img=(System.Web.UI.HtmlControls.HtmlImage)e.Item.FindControl("iPhoto"); //create a relative path for image and add onclick function img.Src=img.Src.Replace('\\', '/'); string Description=""; string Image; Image=IMGpath(img.Src); img.Attributes["onclick"]="showImg('"+Image+"')"; } function showImg(imgName,Description) { imgOn = ("" + imgName); document.imgLarge.filters[0].Apply(); document.imgLarge.src = imgOn; hdr.innerHTML=imgName; document.imgLarge.filters[0].Play(); Jin
-
:(I have a repeater control to display thumbnail pictures. The itemtemplate is made of html image control. When user clicks on the thumbnail picture, I want it to display a larger image and display the image description in a label( the image description is saved in database). The large image is also a html control. My current code is : I have a getPhoto function which will get the thumbnail pictures through IhttpHandler and bound to the repeater control. Then I have a repPhotoG_ItemDataBound function, here I add the javascript to the image html control and call a javascript to pass the thumbnail imagename as parameter and show the large image. All this works fine, but I just don’t know how to get and display the image description. Please help!! private void repPhotoG_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { //finding repeater item Image System.Web.UI.HtmlControls.HtmlImage img=(System.Web.UI.HtmlControls.HtmlImage)e.Item.FindControl("iPhoto"); //create a relative path for image and add onclick function img.Src=img.Src.Replace('\\', '/'); string Description=""; string Image; Image=IMGpath(img.Src); img.Attributes["onclick"]="showImg('"+Image+"')"; } function showImg(imgName,Description) { imgOn = ("" + imgName); document.imgLarge.filters[0].Apply(); document.imgLarge.src = imgOn; hdr.innerHTML=imgName; document.imgLarge.filters[0].Play(); Jin
1. If you are using ASP.NET 2.0 then you can use client callback functionality to get the description from the database and fill the description label. 2. otherwise like passing image path to the javascript funciton you can also pass the description. rsankarindia