ImageButton ?

Discussion in 'ASP .Net' started by TM, Apr 22, 2004.

  1. TM

    TM Guest

    I have this line below coded in the aspx/html at design time:

    *****************
    <TD>
    <asp:ImageButton id="Imagebutton1"
    onmouseover="this.src='<%=MyImage2%>'"
    onmouseout="this.src='<%=MyImage1%>'"
    runat="server" ImageAlign="Left"
    ImageUrl="<%=MyImage1%>">
    </asp:ImageButton>
    </TD>
    *****************

    "MyImage1" and "MyImage2" are c# string variables contain the physical paths
    initialized during page_load operation.

    When hovering the ImageButton1, I got a "RED X" image instead of the real
    image. I displayed the path of MyImage1 & 2 and they both show valid images.

    Thanks,

    Thomas
    TM, Apr 22, 2004
    #1
    1. Advertising

  2. TM

    Dan Guest

    Hover over the broken image, right click and select Properties. Then check
    the image path it shows...

    "TM" <> wrote in message
    news:%...
    > I have this line below coded in the aspx/html at design time:
    >
    > *****************
    > <TD>
    > <asp:ImageButton id="Imagebutton1"
    > onmouseover="this.src='<%=MyImage2%>'"
    > onmouseout="this.src='<%=MyImage1%>'"
    > runat="server" ImageAlign="Left"
    > ImageUrl="<%=MyImage1%>">
    > </asp:ImageButton>
    > </TD>
    > *****************
    >
    > "MyImage1" and "MyImage2" are c# string variables contain the physical

    paths
    > initialized during page_load operation.
    >
    > When hovering the ImageButton1, I got a "RED X" image instead of the real
    > image. I displayed the path of MyImage1 & 2 and they both show valid

    images.
    >
    > Thanks,
    >
    > Thomas
    >
    >
    Dan, Apr 22, 2004
    #2
    1. Advertising

  3. Hi, Thomas,

    The reason is that you mix up the ASP.NET control with old asp code.
    The asp:ImageButton will be initialized on page_init event. however, "<%=", which equals to Response.write, might occur after page_load.
    You'd bette do in either ASP.NET or old ASP way.
    In HTML source:
    <TD><asp:ImageButton id="Imagebutton1"
    runat="server" ImageAlign="Left"
    </asp:ImageButton></TD>
    In Page_PreRender event of Code-behind:
    Imagebutton1.ImageUrl = MyImage1
    Imagebutton1.Attributes("onmouseover") = "this.src='" & MyImage2 & "''"
    Imagebutton1.Attributes("onmouseout") = "this.src='" & MyImage1 & "''"

    Bin Song, MCP

    ----- TM wrote: -----
    <TD><asp:ImageButton id="Imagebutton1"
    onmouseover="this.src='<%=MyImage2%>'"
    onmouseout="this.src='<%=MyImage1%>'"
    runat="server" ImageAlign="Left"
    ImageUrl="<%=MyImage1%>"></asp:ImageButton></TD>

    I have this line below coded in the aspx/html at design time:

    *****************
    *****************

    "MyImage1" and "MyImage2" are c# string variables contain the physical paths
    initialized during page_load operation.

    When hovering the ImageButton1, I got a "RED X" image instead of the real
    image. I displayed the path of MyImage1 & 2 and they both show valid images.

    Thanks,

    Thomas
    =?Utf-8?B?QmluIFNvbmcsIE1DUA==?=, Apr 22, 2004
    #3
  4. TM

    TM Guest

    Bin,

    Thanks. It works now.

    Thomas
    TM, Apr 23, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marcelo

    Prevent Postback with ImageButton

    Marcelo, Jul 1, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    905
    Kairi Zikpin
    Jul 1, 2003
  2. ganesh kolappan

    image/imagebutton client validation

    ganesh kolappan, Jul 3, 2003, in forum: ASP .Net
    Replies:
    2
    Views:
    475
    David Waz...
    Jul 3, 2003
  3. Matthew
    Replies:
    2
    Views:
    557
    Ken Cox [Microsoft MVP]
    Jul 9, 2003
  4. Edmilson

    Imagebutton over a little text

    Edmilson, Jul 30, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    368
    Steve C. Orr, MCSD
    Jul 30, 2003
  5. Jake
    Replies:
    2
    Views:
    395
Loading...

Share This Page