473,770 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Im ageUrl = ModuleSettings. DocThumbWebURL +
strPageFileName ;
imgPageThumb.He ight = Unit.Pixel(85);
imgPageThumb.Bo rderWidth = 3;

plcPageThumbs.C ontrols.Add(img PageThumb);
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('imgDo cThumb', '" + 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 2630
Got it guys, if the answer was any bigger, it would have bitten me:
imgPageThumb.At tributes.Add("O NCLICK", "movepic('imgDo cThumb', '" +
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
4412
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 image in a byte of what is in the database. I also want to be able to display this image in an <asp:image></asp:image> control. Is there any way to do this? Most of the examples that I've seen have used
6
2648
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 multi-lingual site (french/english). Any advice would be appreciated - if there is better way to do this I'd be open to it as well. TIA Clayton
2
1373
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 attribute? Is it some sort of relative addressing? On the design surface, that shows as an error until I change it to read:
0
1252
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 empty alt attribute in the resulting image tag. - Not much of a problem you might think, but the image is contained in a table cell where the title attribute is set and thus the image's empty alt tag overrides this title tag. Has anyone else had...
4
2003
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
2582
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? Thanks much
3
7917
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 specified do not exist, as it displays a red cross and the alternate text. What I would like to do is display a default image instead.
2
2048
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
2079
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 Image, code is below: <asp:Image ID="imgLarge" Name="imgLarge" runat="server" AlternateText="Large Custom Image" Height="300" Width="400" /> <asp:Repeater ID="rptSmall" runat="server" OnItemDataBound="rptSmall_ItemDataBound1">
0
9619
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10102
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8933
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6712
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4007
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.