CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Aug 2007
    Posts
    47

    Question hyperlink onmouseover

    hi... why does this work (btnContinue is an ImageButton)?

    btnContinue.Attributes.Add("OnMouseOver", "this.src='/site/images/start-over.png'");
    btnContinue.Attributes.Add("OnMouseOut", "this.src='/site/images/start-up.png'");

    and this doesn't (HyperLink):
    HyperLink1.Attributes.Add("OnMouseOver", "this.src='/site/images/print-over.png'");
    HyperLink1.Attributes.Add("OnMouseOut", "this.src='/site/images/print-over.png'");

    how can i change the image using HyperLink webcontrol?
    i need some help...
    i don't know what property i have to use so it can work...

    thanks in advance...

  2. #2
    Join Date
    Apr 2005
    Location
    Norway
    Posts
    3,934

    Re: hyperlink onmouseover

    A hyperlink doesn't know what an image is (or any src property). But you can put an image 'inside' a hyperlink.

    Code:
    <asp:HyperLink NavigateUrl="~/Default.aspx" runat="server" ID="lnk">
        <img id="ImageInHyperlink" src="Controls/marker_top.gif" alt="" />
    </asp:HyperLink>
    Then in your codebehind add:
    Code:
    lnk.Attributes.Add("OnMouseOver", 
        "document.getElementById('ImageInHyperlink').src='imageA.gif'");
    lnk.Attributes.Add("OnMouseOut", 
        "document.getElementById('ImageInHyperlink').src='imageB.gif'");
    - petter

  3. #3
    Join Date
    Aug 2007
    Posts
    47

    Thumbs up Re: hyperlink onmouseover

    thanks, it worked...
    the only thing it didn't do was changing mouse behavior...
    with ImageButtons it changes from arrow to hand...
    and it didn't do it automatically...

    i'll see what i can do...

  4. #4
    Join Date
    Aug 2007
    Posts
    47

    Resolved Re: hyperlink onmouseover

    my mistake

    forget about the mouse cursor stuff...
    i had removed the hyperlink's url, that's why i was not getting the hand cursor..

    thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured