Question Need Help with imageButton rollover image inside repeater


New member
Apr 30, 2012
Programming Experience
I'm trying to add roll-over images to my imageButtons inside a repeater using the various techniques I've found online.
Essentially, my initial artwork ends in I.png and my hover artwork ends in H.png. All of the paths and attributes are being inserted correctly.

From the Page:
            <asp:Repeater ID="Repeater1" runat="server" DataSourceID="GatewayDataSource" OnItemDataBound="Repeater1_OnItemDataBound">
                    <asp:ImageButton ID="ImageButton1" runat="server" 
                    ImageUrl='<%# "~/Images/Gateways/" & Eval("artworkInitial") %>' 
                        PostBackUrl='<%# Eval("domain") & Eval("redirect") %>' ToolTip='<%# Eval("toolTip") %>' CssClass="GatewayArtwork" />
The Code Behind:
    Protected Sub Repeater1_OnItemDataBound(ByVal sender As Object, ByVal e As RepeaterItemEventArgs)
        Dim Button As ImageButton = CType(e.Item.FindControl("ImageButton1"), ImageButton)
        Dim Iurl As String = Button.ImageUrl
        Dim Hurl As String = Iurl.Substring(0, Iurl.Length - 5)
        Hurl &= "H.png"
        Button.Attributes.Add("OnMouseOut", "this.src='" & Iurl & "';")
        Button.Attributes.Add("OnMouseOver", "this.src='" & Hurl & "';")
    End Sub

I believe my problem is that when the page is rendered, the apostrophes in my OnMouseOut and OnMouseOver are being replaced with (& # 3 9 ; ) - Obviously, that should all run together, but pasting it here caused it to be replaced with an actual apostrophe...which is what should be happening in my case.

Screenshot of Firefox View Source code as PNG and JPG:

Thanks in advance!


  • Screenshot.png
    3.8 KB · Views: 24
  • Screenshot.jpg
    18 KB · Views: 21
Last edited:
Top Bottom