Click here to Skip to main content
15,884,739 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Dear Experts,
I have a gridview having images in a cell. I just want to show and hide that image from javascript.

inside gridview template field
<img id="img1" alt="" src="../images/LoadingImage.gif" />
Posted

I solved myself. Solution is given below:-

var grdvw = document.getElementById("GridView1");
C#
for(var i = 1; i < grdvw.rows.length; i++)
{
grdvw.rows[i].cells[0].getElementsByTagName('img')[0].style.visibility='visible'; //for hide grdvw.rows[i].cells[0].getElementsByTagName('img')[0].style.visibility='hidden';
}
 
Share this answer
 
XML
add onclick function to it. onclick="javascript:ShowHideImage(this);"

<script>
function ShowHideImage(imgelement)
{
// Your code goes here;
}
</script>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900