473,378 Members | 1,417 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

Adding Some Javascript to an ASP:IMAGE control

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

Nov 19 '05 #1
1 2607
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

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: John Scott | last post by:
I am storing an image in an SQL database and have one field as an image datatype. I am also using a webservice to transport data. I want to be able to resize the image and pass back a thumbnail...
6
by: C K | last post by:
What is less expensive/intensive on the server -dynamically writing out my rollovers to an asp:literal, or to use asp:image tags for the images. My image names will be dynamic as I am building a...
2
by: Chris Dunaway | last post by:
I was looking over some asp.net code and saw this asp:Image control: <asp:Image ImageUrl="~/images/logo.gif" runat="server" ID="Image1"/> What does the tilde (~) mean in the ImageUrl...
0
by: mortb | last post by:
Hi I've created an image control of my own as a decendant of asp:image My problem is that when rendered on the production server (not in my development environment though) this control renders an...
4
by: Sparky Arbuckle | last post by:
Does anyone know of a way to add an image into a DataGrid's Template Column? Any suggestions are greatly appreciated.
8
by: MarkAurit | last post by:
I have to display some images kept into a sql server database (image data type) in an asp.net 1.1 page. Is it possible to use an asp control to display the contents of a byte or a MemoryStream?...
3
by: Paul Cheetham | last post by:
Hi, I have an application that will display user-defined images in some asp:image controls. (sets the ImageURL, and is always built from the site root) The problem comes when the images...
2
Steve Kiss
by: Steve Kiss | last post by:
Is there a way to add javascript functionality, onmouseover to be specific, to an image defined with <asp:Image />?
0
by: Sully | last post by:
Hi Guys, I have this about 98% done and I cannot get it work properly. I have a Repeater bound to a MySQL DataSource, inside the Repeater I have an ImageButton, outside the repeater I have a...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.