ImageButton ?

T

TM

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
 
D

Dan

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

Guest

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
 

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. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top