Image control not getting src

D

David C

I have an asp:Image control that I want to have it's src url to change using
OnClientClick of a set of images in a DataList. All works fine, except the
single Image control is not displaying the image, just a red X. My separate
DataList records have this
OnClientClick="return showpic(this);"

The javascript function is as follows:

function showpic(obj)
{
var bigpic = document.getElementById("ImgLarge");
bigpic.className = 'Show';
bigpic.src = obj.src;
return false;
}


Any ideas what I am doing wrong? Thanks.

David
 
B

bruce barker

one of two possibilities.

1. you are using the images real id, try:

var bigpic = document.getElementById("<%=ImgLarge.ClientID%>");

2. your onclick is not attached to an image so src is undefined. view
source to see which html control showpic is attached to.


-- bruce (sqlwork.com)
 
D

David C

Below is how I solved it. I made a variable for obj.src and then it worked.
Thanks.

function showpic(obj)

{

var bigpic = document.getElementById("ImgLarge");

bigpic.className = 'Show';

var varsrc = obj.src;

bigpic.src = varsrc;

return false;

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top