Change Dynamic Image Source on Mouse over and Mouse Out

Posted on 2006-05-19
Last Modified: 2006-11-18
Hi All

I currently have image holders on ASPX2 being dynamically populated from an Access database (an ID number from ASPX1 is retrieved and used to query the database to retrieve img src urls on ASPX2 through an Image.aspx page). Once popluated upon mouse over the IMG1, IMG 0 changes with respective thumbnail picture, but as you can see below, I have the url statically populated. How can I retrieve the urls from the images after their are being pulled from the database? How can I reference the respective image sources in the place of the static paths?

<a style="cursor:hand" ONMOUSEOVER="changeImages('IMAGE0', 'graphics/Homes/1041 Doral CourtM1.gif'); return true;" ONMOUSEOUT="changeImages('IMAGE0', 'graphics/Homes/1041 Doral CourtT1.gif'); return true;">
                <asp:Image NAME = "IMAGE1"  ID="Img1" runat="server" Height="95px" Width="126px" BorderColor="#E0E0E0" BorderWidth="1px" ImageUrl="~/graphics/blank.gif" /></td>\


<a style="cursor:hand" ONMOUSEOVER="changeImages('IMAGE0', 'Image.aspx?CID=11&PID={DE8822E6-9CEA-4CF2-80ED-56D108B30DBC}'); return true;" ONMOUSEOUT="changeImages('IMAGE0', 'Image.aspx?CID=10&PID={DE8822E6-9CEA-4CF2-80ED-56D108B30DBC}'); return true;">
                <asp:Image NAME = "IMAGE1"  ID="Img1" runat="server" Height="95px" Width="126px" BorderColor="#E0E0E0" BorderWidth="1px" ImageUrl="~/graphics/blank.gif" /></td>

Question by:acancel
    LVL 25

    Accepted Solution

    Need to do from code-behind:

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default6.aspx.cs" Inherits="Default6" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

    <html xmlns="" >
    <head runat="server">
        <title>Untitled Page</title>
        <form id="form1" runat="server">
            <asp:Image ID="Image1" runat="server" ImageUrl="" /></div>

    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;

    public partial class Default6 : System.Web.UI.Page
        protected void Page_Load(object sender, EventArgs e)
            this.Image1.Attributes.Add("onmouseover", "javascript:this.src=''");
            this.Image1.Attributes.Add("onmouseout", "javascript:this.src=''");


    LVL 19

    Expert Comment

    by:Melih SARICA
    <a style="cursor:hand" ONMOUSEOVER="javascript:this.src='Image.aspx?CID=11&PID={DE8822E6-9CEA-4CF2-80ED-56D108B30DBC}';" ONMOUSEOUT="javascript:this.src='Image.aspx?CID=10&PID={DE8822E6-9CEA-4CF2-80ED-56D108B30DBC}'">
                    <asp:Image NAME = "IMAGE1"  ID="Img1" runat="server" Height="95px" Width="126px" BorderColor="#E0E0E0" BorderWidth="1px" ImageUrl="~/graphics/blank.gif" /></td>

    try this

    Featured Post

    Gigs: Get Your Project Delivered by an Expert

    Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

    Join & Write a Comment

    Suggested Solutions

    User art_snob ( encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now