Adding Some Javascript to an ASP:IMAGE control

X

xanthviper

Hey there,


I'm kind of stumped on this and hopefully someone can guide me in the
right direction.


I have a webform that I am developing in C# using ASP.NET 2.0. On the
page_load, I am getting some information from a database query telling
me how many images I need to show on the page. Since this count can be
dynamic, I am doing the following code to add images to a PLACEHOLDER
already on the ASPX file:


Image imgPageThumb = new Image();

imgPageThumb.ImageUrl = ModuleSettings.DocThumbWebURL +
strPageFileName;
imgPageThumb.Height = Unit.Pixel(85);
imgPageThumb.BorderWidth = 3;

plcPageThumbs.Controls.Add(imgPageThumb);


This works pretty well and everything is good. The next thing I am
trying to do is add a javascript command to either ONMOUSEOVER or
ONCLICK TO execute some javascript that will change my image for me.
Basically a rollover if you will.


"movepic('imgDocThumb', '" + ModuleSettings.DocThumbWebURL +
strPageFileName + "')";

thats where the problem comes in, I have no clue how to add it to any
of the clientside events.


I have tried doing this is an actual IMAGE button. This works great,
however if a client CLICKS on the image button, it will perform the
clientside ONCLICK, but then also perform a post-back which is
something I don't want to do.


Hopefully someone has an idea on this and I would really appreciate any
help you may have.

TIA
 
X

xanthviper

Got it guys, if the answer was any bigger, it would have bitten me:


imgPageThumb.Attributes.Add("ONCLICK", "movepic('imgDocThumb', '" +
ModuleSettings.DocThumbWebURL + strPageFileName + "')");


Basically, I just added an Attribute to the ASP:IMAGE object I was using
 

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

Members online

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,077
Latest member
SangMoor21

Latest Threads

Top