problem with image swapping on imagebutton

Discussion in 'ASP .Net' started by Jeff, Apr 29, 2009.

  1. Jeff

    Jeff Guest

    hi 3.5

    <asp:ImageButton ID="ImageButton1" ImageUrl="~/Images/normal.gif"
    runat="server" />

    protected void Page_Load(object sender, EventArgs e)
    if (!Page.IsPostBack)

    when the page loads it displays the ImageButton with the correct image, but
    when I hover the mouse over the image then I get a broken image icon. when I
    move the mouse away from the ImageButton I still get the broken image

    any ideas what I do wrong here?
    Jeff, Apr 29, 2009
    1. Advertisements

  2. Try:

    HttpContext.Current.Request.ApplicationPath.ToString + "/Images/hover.gif'");
    HttpContext.Current.Request.ApplicationPath.ToString + "/Images/normal.gif'");
    William Niver, Apr 29, 2009
    1. Advertisements

  3. What I posted here would be incorrect.
    It would be:

    this.src='" + HttpContext.Current.Request.ApplicationPath.ToString +

    You are adding Javascript event handlers as attributes to the final img tag
    that's being produced in HTML. You want the onmouseover and onmouseout
    events to change teh img tags src attribute. I didn't add the
    "this.src="[file path]" in my previous post, my appologies.
    William Niver, Apr 29, 2009
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.