?
Solved

Change Dynamic Image Source on Mouse over and Mouse Out

Posted on 2006-05-19
2
Medium Priority
?
326 Views
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>\

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
0
Comment
Question by:acancel
2 Comments
 
LVL 25

Accepted Solution

by:
nauman_ahmed earned 375 total points
ID: 16721502
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
 
LVL 19

Expert Comment

by:Melih SARICA
ID: 16721544
<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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month16 days, 7 hours left to enroll

862 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