onmouseover/onmouseout event on Hyperlink

Hi 

I have a hyperlink with an image inside of it. I would like the image to change when the user does a mouseover. Is this possible with a hyperlink?

<asp:HyperLink ID="hypVisit" runat="server" ImageUrl="Images/WEBSITE_UP.jpg" Target="_blank">HyperLink
                </asp:HyperLink>

onmouseover = WEBSITE_DOWN.jpg


Rob

"Man is the best computer…and the only one that can be mass produced with unskilled labour”
0
Elmbrook
5/5/2009 6:14:19 AM
asp.net.web-forms 93655 articles. 2 followers. Follow

6 Replies
3254 Views

Similar Articles

[PageSpeed] 16

You can use styles.

<style type="text/css">
a:hover{ background-image:url }
</style>


Bind GridView to Dynamically created DataTable | Bind DataTable to DropDownList

My Blog
-1
shahed
5/5/2009 6:19:08 AM

You need to add the onmouseover and onmouseout attributes to the hyperlink:

hypVisit.Atrributes.Add("onmouseout", "mouseout()");

hypVisit.Atrributes.Add("onmouseover", "mouseover()");

Finally add some JavaScript:

<script language="JavaScript" type="text/javascript">
<!--

function mouseover()
{
document[YOUR-IMAGE-NAME].src = "mouseoverimage.jpg" );
}

function mouseout()
{
document[YOUR-IMAGE-NAME].src = "mouseout.jpg" );
}

// -->
</script>
Give that a try.

Sincerely,
Malcolm Sheridan
Microsoft Certified Solution Developer
Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as
Answer" if a marked post does not actually answer your question.
2
malcolms
5/5/2009 6:19:36 AM

hi

please go with above mentioned solution it is perfect

0
hiral
5/5/2009 6:31:10 AM

Place the below code on page_load event. 

hypVisit.Attributes.Add("onMouseOver","this.firstChild.src='/Images/WEBSITE_DOWN.jpg")


Please mark it as answer if it resolves the issue.

visit: http://technicalsol.blogspot.com
1
sumitd
5/5/2009 6:32:09 AM

Hi,try this:

<asp:HyperLink ID="hypVisit" onmouseover="changeImage()" runat="server" ImageUrl="Images/WEBSITE_UP.jpg" Target="_blank">HyperLink

</asp:HyperLink>

function changeImage()

{

var image = document.getElementById("<%=hypVisit.ClientID %>");image.imageurl = "ImageUrl"; //Give your image url here

}

For mouseover event you will not get intellisence then only it will work.You can write that event.

Thanks,

Khushboo Nayak

Please Mark as Answered if this helps you.

-1
khushi_nayak
5/5/2009 6:41:40 AM

 ok, I have tried all the solutions and they don't seem to be working.

I have swap image code already (Dreamweaver creates it) and that works with other things.

    function MM_swapImage() { //v3.0
        var i, j = 0, x, a = MM_swapImage.arguments; document.MM_sr = new Array; for (i = 0; i < (a.length - 2); i += 3)
            if ((x = MM_findObj(a[i])) != null) { document.MM_sr[j++] = x; if (!x.oSrc) x.oSrc = x.src; x.src = a[i + 2]; }
    }


     function MM_swapImgRestore() { //v3.0
        var i, x, a = document.MM_sr; for (i = 0; a && i < a.length && (x = a[i]) && x.oSrc; i++) x.src = x.oSrc;
    }
 

My hyperlink which does not work is the following

                <asp:HyperLink ID="hypVisit" runat="server" ImageUrl="Images/WEBSITE_UP.jpg" Target="_blank" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('hypVisit','','Images/WEBSITE_OVER.jpg',1)">HyperLink
                </asp:HyperLink>

My Image button which does work has the following

<asp:ImageButton id="btnEmail" runat="server" onclick="btnEmail_Click" imageurl="Images/EMAIL_UP.jpg" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('btnEmail','','images/EMAIL_OVER.jpg',1)" />
                

From that, can anybody work out why it is not working or get it working?


Rob

"Man is the best computer…and the only one that can be mass produced with unskilled labour”
1
Elmbrook
5/5/2009 6:58:46 AM
Reply:

Similar Artilces:

How to fire events in other web form from other web form ?
Suppose that I have A and B web form. I want to trigger B web form's Page_Load event from A web form. How can I do that ? Thanks in advanced WilbertWilbert Bujn Create a public method in B that call the load method : public void Load(object sender, System.EventArgs e) { Page_Load(sender, e) ; } In the page_load of A, instanciate a B object and then call the function B myB = new B() ; myB.Load() ; Quicky Thank you quicky, it works fine. WilbertWilbert Bujn...

Implementing .Net Form into an APS.net web form, can this be done
I am new here, but have been searching for a while, and may not have the correct lingo to find what I am looking for.  I am tasked with implementing a .exe application that was writen vb6 then converted to .net into a new website my team is developing. The idea is to put each of the 3 different forms in this .exe application of 3 different .aspx pages. I have attempted multiple things to get this into the page and even started to just rewrite it as an ASP.net web form, but even then I can't reuse any of the code since the System.Web.UI.Page doesn't inherit the sa...

How to add event to Web Form from the vs.net designer
 Hi there, I know that when i double click a web form I'm taking to the page_load event.  However, I want to create an unload event by I don't know how to create it from the vs.net designer.  Does anybody know how to create a page unload event from the vs.net designer? Many thanks  Page events are not exposed in the design view. If you are using VB, you should be able to use dropdowns on top of the code editor -> select Page in the left one and the designed event in the right one and editor will generate the code. Unfortunately, C# editor does not p...

.NET 1.1 Web Form
I am scratching my head trying to figure out why my events button (Lighting Bolt) is not displaying when I select buttons in Visual Studio 2003.  Has anybody had this happen before? I am tired into Visual Source Safe and wonder if that has anything to do with it?Moojjoo Õ¿Õ http://www.mmwebs.comhttp://moojjoo.blogspot.com/ Ummm>>>   That is the difference between C# and VB.NET.  VB.NET does not display the Lightning Bolt under properties in VS 2003.Moojjoo Õ¿Õ http://www.mmwebs.comhttp://moojjoo.blogspot.com/...

windows forms in vb .net into web forms
we are creating a database driven website as part of our project. currently we have forms connecting to the database created in visual basic. these windows forms we need to convert into web forms which are asp .net compatible. can u give me an answer or show me a way. Hi, because of the difference in nature between web and win applications you'll need to reimplement at least the UI part. If you have a multitiered application in which the busines logic and data access are in different parts/assemblies you can reuse them. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Wor...

.Net Web Form & Web Service Deployment
Hi all I have written some test web services and some web form applications and deployed them to my IIS. That's fine but I now want to deploy them to my real IIS server. I have created an msi for each but the problem is I seem to only be able to deploy to the default web site. Our default web site is turned off and instead we use several other sites. Does anybody happen to if Powerbuilder 11 supports non default web sites? If not do I need to hack the msi and if so can anybody suggest a suitable tool. I have Orca but it's not very friendly. Unless of course I knew exactly w...

How to Make Web Forms from other Web Forms
In putting together an ASP.NET application for a biz application, we have come to the point where there are three different types of basic forms which have, for the most part, been perfected. Now its is a matter of cloning those forms for various uses and modifying or adding code to suit the particular need. Copy and paste works OK, but there is a lot of changing of certain words, etc. Is there a way in ASP.NET to take these basic forms, turn them into classes or templates, create forms from them, then add or overwrite code? ? (Anybody who is a Vis Fox Pro programmer would know imme...

Web forms and mobile web forms
Hey everyone, I am looking to develope a web site that depending on the device connecting to it, it will display a certain page. In this case im looking to create a web and wap version of the same project. I have the Web forms version finished using ASP.NET and C# and I am wondering how to create the mobile web form and incorporate it in the project. In the project folder, can I just add a mobile web??? But what about displaying device specific pages?? Cheers -Dudach Yes, you can add mobile web forms and controls to your Web Application project. No problem. For device/br...

Event handling web user control buttom in web form
How would I handle the button1 click event from a web user control on a web form in the codebehind? Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click MsgBox("test") End Sub does not work. Button1 is in the web user control. How would one handle the event in the page the web user control is embedded in? nevermind. it all came down to the class declaration in the codebehind file for the user control. It was originally webusercontrol2 and I renamed the ascx file to datesel.ascx and it never changed t...

For interrupting.web form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form
Web Form Resized by position of the div : if div can't dispaly all (such as only top part , then web form heithten the heght),resize the web form ! Because of my pool English, if you can't see , I will explain more ! ThanksGambler is the real life I guess you mean when form grows it also grow parent div element. This is normal. If you want div to stay fixed size and rather clip the form and maybe show a scrollbar, look at overflow property in CSS.Thanks------------------------------------------------------------This posting is provided "AS IS" with no warranties, and confers no ...

Web forms and events
 A design issue regarding web forms user interfaces has been bugging me for some time. It is an "order of events" issue, which good design should eliminate right.. but how? Lets say I have written a User Control which takes some input from the user. In order to encapsulate the User Control, I've created an event which the control fires when (if) the user has made some sort of change. The event tells other parties (ie. the parent page) both the fact that the user has done something, and event data tells us what they did.Now, I drop the User Control onto a page. The pag...

How To Convert c#2005.net web template to vb2005.net Forms Template
I need  Convert c#2005.net web template to vb2005.net Forms Template   There are some free c# to vb converters out there which will allow you to upload a project and convert it to vb.   The programming models for windows forms and web projects are very different there is no way to convert a web to windows forms project.   http://www.carlosag.net/Tools/CodeTranslator/Default.aspx      Silverlight-helpVb TipsSpace Coast .Net User Group Hey Ajax-y, This tool really helps all programmers. I thought I would share this wit...

OnMouseOver and OnMouseOut Events
 Hello All,My question is that I am using ImageButton server control in my .aspx page, now I want to implement OnMouseOver and OnMouseOut events for this particular image button server control, what should I have to do? Please help me for solving my problem and give your response as soon as possible. Thanks in advance.   You can do like this... <asp:ImageButton ID="imageButton1" runat="server" onmouseover="return mouseOverFun();" onmouseout="return mouseOutFun();" /> <script type="text/javascript">function ...

.Net Web Forms
what is the best way to create a multi-page web insurance quote form (similar to Geico) that will insert information into a database? The examples i've seen show one form with a submit button at the bottom. I need to break this form into at least three different aspx or ascx pages. Thanks for the help. I did something similiar since I have like 7 sections to an application. The way I did it was by using the asp:panel control. When the user finished one section and clicks a button it inputs the data into the database and hides the 1st panel and shows the next one. HTH...

Web resources about - onmouseover/onmouseout event on Hyperlink - asp.net.web-forms

Twitter OnMouseOver Error Causes Popups
A Twitter "onMouseOver" error propagated on Twitter early this monring. The error allowed "tweets" containing blocked-out text to appear on Twitter. ...

Twitter Explains Away “onMouseOver” Attack
After receiving numerous reports from the twitterverse and blogosphere, Twitter has finally posted an explanation regarding the “onMouseOver” ...

'Rainbow tweets' start hammering Twitter after onMouseOver exploit discovered
Oh dear. Some wise guys have discovered a JavaScript exploit in Twitter's web interface, which uses an onMouseOver instruction to hijack your ...

Twitter Attack Using onmouseover Shows Why I Hate Mouse Overs
... found that it was really easy to fall prey to an exploit that took advantage of something that is all too common on so many sites, using onmouseover ...

OnMouseOver XSS plagues Twitter - Update
A new wave of Twitter attacks, which make use of an XSS vulnerability in Twitter's web client, is causing trouble for Twitter users

'OnMouseOver' Twitter Security Flaw Takes Over Twitter.com (UPDATED)
UPDATE: Twitter has published a blog on the "OnMouseOver incident," explaining what happened, why, and how Twitter responded.UPDATE: Twitter ...

Twitter: Site Update Unleashed 'OnMouseOver' XSS Exploit
Twitter on Tuesday blamed this morning's "onMouseOver" incident on a recent site update that unknowingly resurfaced a site exploit it discovered ...


Warning: Onmouseover Twitter Security Flaw Is Wreaking Tweet Havoc [Updated]
BREAKING: Post javascript into your status update on Twitter and you can make something appear in the pop-up as a user mouses over your tweet. ...

Techmeme: Twitter ‘onmouseover’ security flaw widely exploited (Graham Cluley/Sophos)
The web's technology news site of record, Techmeme spotlights the hottest tech stories from all around the web on a single page.

Resources last updated: 1/20/2016 6:37:44 PM