Change Dynamic Image Source on Mouse over and Mouse Out

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>\

SHOULD BE SOMETHING LIKE:

<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>

Thanks
acancelAsked:
Who is Participating?
 
nauman_ahmedCommented:
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" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Image ID="Image1" runat="server" ImageUrl="http://www.google.com/intl/en/images/logo.gif" /></div>
    </form>
</body>
</html>

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='http://www.google.com/images/google_sm.gif'");
        this.Image1.Attributes.Add("onmouseout", "javascript:this.src='http://www.google.com/intl/en/images/logo.gif'");

    }
}

-Nauman.
0
 
Melih SARICAOwnerCommented:
<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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.