locked
Change image button image on hover RRS feed

  • Question

  • User-1540430490 posted

    Hoep this si simple I would like to change the image in an image button when the user hovers over it ..can anyone help

    Thanks

     


     

    Tuesday, June 19, 2007 4:42 AM

Answers

  • User-1790346045 posted

    Hi, Paul:

    Here is an example to show how to achieve this. 

     <asp:ImageButton id="ImageButton1"
                 onmouseover="this.src='button2.jpg'"
                 onclick="ImageButton1_Click"
                 onmouseout="this.src='button1.jpg'" runat="server"
                 ImageUrl="button1.jpg"></asp:ImageButton>

    Hope it helps.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 20, 2007 4:45 AM
  • User-2106054853 posted

    Hi:
      Just try this:

    <input type="image"  onmouseout="this.src='http://forums.asp.net/themes/fan/style/i/avatar_null_59x59.jpg'" onmouseover="this.src='http://forums.asp.net/users/avatar.aspx?userid=713722&amp;lastmodified=633167037070572486'" onclick="" runat="server" id="imagebutton1" src="http://forums.asp.net/themes/fan/style/i/avatar_null_59x59.jpg" />


    Hope it helps.

    Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 20, 2007 4:52 AM

All replies

  • User-1790346045 posted

    Hi, Paul:

    Here is an example to show how to achieve this. 

     <asp:ImageButton id="ImageButton1"
                 onmouseover="this.src='button2.jpg'"
                 onclick="ImageButton1_Click"
                 onmouseout="this.src='button1.jpg'" runat="server"
                 ImageUrl="button1.jpg"></asp:ImageButton>

    Hope it helps.

     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 20, 2007 4:45 AM
  • User-2106054853 posted

    Hi:
      Just try this:

    <input type="image"  onmouseout="this.src='http://forums.asp.net/themes/fan/style/i/avatar_null_59x59.jpg'" onmouseover="this.src='http://forums.asp.net/users/avatar.aspx?userid=713722&amp;lastmodified=633167037070572486'" onclick="" runat="server" id="imagebutton1" src="http://forums.asp.net/themes/fan/style/i/avatar_null_59x59.jpg" />


    Hope it helps.

    Regards

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, June 20, 2007 4:52 AM
  • User-703432812 posted

     Just out of interest, why are these properties not available in the properties box and I've noticed they are also underlined in the code view as if they are a syntax error?

    Monday, September 17, 2007 8:34 AM
  • User-471984401 posted

    Hi there

    I tried the code but onmouseover and onmouseout tells me that they are not attributes of the imagebutton.

     

     

    cliff

     

    Friday, March 14, 2008 11:19 AM
  • User-552854503 posted

    this is an old thread, but to just answer the question:

     you can add the onmouseover and onmouseout using the Attributes property of the ImageButton:

    ImageButton button = new ImageButton();
    button.ImageUrl = <your url>
    ;
    button.Attributes.Add("onmouseover", "javascript:this.src='<your url>'");
    button.Attributes.Add(
    "onmouseout", "javascript:this.src='<your url>'");

     remember you need to refer to a server url for the ImageUrl property and a relative url for the Attributes

     Kind Regards,

    Didier

    Thursday, March 12, 2009 8:06 AM
  • User870762792 posted

    No you need to write a javascript function! this is totally erroneous. 

     

    Sunday, September 5, 2010 5:42 AM
  • User1917358531 posted

    PMarchand

    I realise this is an old post but you can add atributes as above..

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
            BackButton.Attributes.Add("onclick", "javascript: history.go(-1); return false;")
        End Sub
    Is an example of a working back button .. Tested in IE and FF
    Monday, August 22, 2011 5:40 AM