[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

imagebutton mouse over event

Posted on 2008-11-17
4
Medium Priority
?
759 Views
Last Modified: 2012-05-05
I want to show an image control on mouse over event of an imagebutton control

this is my image button
 <asp:ImageButton ID="ImageButton1" runat="server"
                    ImageUrl="~/images/newimages/selectBtn.jpg" />

and my image control is this one
<asp:Image ID="Image31" runat="server"
                    ImageUrl="~/walkthrough/images/Blank.jpg" />
0
Comment
Question by:gianitoo
  • 2
4 Comments
 
LVL 10

Expert Comment

by:gangwisch
ID: 22978360
imagebutton1.attributes.add("onmouseover()","changeimg()")

then write a javascript function to change image31

function changeimg()
{
document.myform.image31.src='myimage.jpg';
}

in order to switch the image back to it's original state use onmouseout:

imagebutton1.attributes.add("onmouseout()","changebackimg()")
0
 
LVL 1

Author Comment

by:gianitoo
ID: 22978662
not working??
I am using asp.net page  
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPageB.master" %>
 
<script runat="server">
 
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
        ' ImageButton1.Attributes.Add("onmouseover", "myfunction(this, 'images/newimages/selectBtnRoll.jpg')")
        ImageButton1.Attributes.Add("onmouseover()", "changeimg()")
        '  ImageButton1.Attributes.Add("onmouseout", "myfunction(this, 'images/newimages/selectBtn.jpg')")
        ImageButton1.Attributes.Add("onmouseout()", "changebackimg()")
        ImageButton2.Attributes.Add("onmouseover", "myfunction(this, 'images/newimages/selectBtnRoll.jpg')")
        ImageButton2.Attributes.Add("onmouseout", "myfunction(this, 'images/newimages/selectBtn.jpg')")
        ImageButton3.Attributes.Add("onmouseover", "myfunction(this, 'images/newimages/selectBtnRoll.jpg')")
        ImageButton3.Attributes.Add("onmouseout", "myfunction(this, 'images/newimages/selectBtn.jpg')")
        ImageButton4.Attributes.Add("onmouseover", "myfunction(this, 'images/newimages/selectBtnRoll.jpg')")
        ImageButton4.Attributes.Add("onmouseout", "myfunction(this, 'images/newimages/selectBtn.jpg')")
        'Image31.Attributes.Add("onmouseover", "myfunction(this, 'images/newimages/125bf.jpg')")
        'Image31.Attributes.Add("onmouseover", "myfunction(this, 'images/newimages/125bf.jpg')")
        
 
    End Sub
</script>
 
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<script language=Javascript>
 
    function changeimg() {
        document.myform.image31.src = 'images/newimages/125bf.jpg';
    }
    function changebackimg() {
        document.myform.image31.src = 'walkthrough/images/Blank.jpg';
    }
 
    function myfunction(me, path) {
        me.src = path;
    }
 
</script>
 
    <table class="style5">
        <tr>
            <td>
 
    <p class="titleboldblack">
        SELECT the mill based off your<br />
        price range<br />
        <br />
                </p>
            </td>
            <td class="titlemenu" rowspan="2" valign="top">
               <span class="titleboldblacksmall">What is a board foot?</span> 
                <br />
                Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor 
                incididunt ut labore et dolore magna aliqua.
                <br />
                <br />
                <asp:Image ID="Image31" runat="server" 
                    ImageUrl="~/walkthrough/images/Blank.jpg" />
            </td>
        </tr>
        <tr>
            <td>
    <table align="center" style="width: 500px">
        <tr>
            <td class="titleboldblack">
                $4000 - $11,999<br />
                <asp:ImageButton ID="ImageButton1" runat="server" 
                    ImageUrl="~/images/newimages/selectBtn.jpg" />
                <br />
                <br />
            </td>
            <td class="titleboldblack">
                $12,000 - $28,999<br />
                <asp:ImageButton ID="ImageButton2" runat="server" 
                    ImageUrl="~/images/newimages/selectBtn.jpg" />
                </td>
        </tr>
        <tr>
            <td class="titleboldblack">
                $29,000 - $34,999<br />
                <asp:ImageButton ID="ImageButton3" runat="server" 
                    ImageUrl="~/images/newimages/selectBtn.jpg" />
                </td>
            <td class="titleboldblack">
                $35,000 - $48,000<br />
                <asp:ImageButton ID="ImageButton4" runat="server" 
                    ImageUrl="~/images/newimages/selectBtn.jpg" />
                </td>
        </tr>
    </table>
            </td>
        </tr>
    </table>
</asp:Content>

Open in new window

0
 
LVL 10

Expert Comment

by:gangwisch
ID: 22981460
because  you dont have the images placed inside a form tag
<form name="myform" id="myform>
<!--images>
</form>
0
 
LVL 1

Accepted Solution

by:
urvinayan earned 2000 total points
ID: 22984307
I see that u are using master page.. So do the following
do imagebutton1.attributes.add("onmouseover()","changeimg()") in codebehind
as gangwisch says...
then change
function changeimg()
{
document.myform.image31.src='myimage.jpg';
}
as
function changeimg()
{
document.getElementById('<%image31.ClientID%>').src='myimage.jpg';
}
 
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

834 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