473,395 Members | 1,919 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

ImageButton ?

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
Nov 18 '05 #1
3 1562
Dan
Hover over the broken image, right click and select Properties. Then check
the image path it shows...

"TM" <Th**************@Yahoo.Com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
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

Nov 18 '05 #2
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

Nov 18 '05 #3
TM
Bin,

Thanks. It works now.

Thomas
Nov 18 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chuck Hartman | last post by:
I've been trying to add an ImageButton object to a Calendar table cell, but so far I am unable to handle the Command event from that button in my form's code behind. Below is an example of what I...
1
by: Tee | last post by:
Hi, I have a server control Table with each row will contain a dynamic created ImageButton. And I have a private sub with the proper delegate of an ImageButton click which handle nothing....
1
by: Henke | last post by:
Hello, I have one ImageButton controls which I initialize in Page_Load and declare on class level. ImageButton save = new ImageButton(); save.ImageUrl = "save.gif" save.Click += new...
3
by: tshad | last post by:
I was trying to change my asp:button to asp:ImageButton, but got a message saying that ImageButton does not have an onClick function. How do I get the ImageButton call a function? Thanks, ...
2
by: CJ Oakwood | last post by:
Morning - I am hoping somebody from this group can help me out here... I have been trying to add an array of ImageButtons to my WebForm however I keep getting an exception that I can't seem to...
0
by: Oddball | last post by:
I have set up a page with uses two lots of image buttons, one for a collection and one for more images from that collection. I generate all the image buttons on page init (I know, but I...
3
by: jens.buchta | last post by:
Hi! I'm using a DataGrid with a template column to display an Image inside of it. I'm hooking into its OnPrerender-Event to set the ImageURL-Property dynamically. Everything works just fine...
3
by: JuniorProgrammer | last post by:
Am trying to add an Image Button into a Datalist at Design time. When I run it it comes up with error: Server tag not well formed. It works perfectly when I add just an Image Control. Please...
4
by: suzanne.boyle | last post by:
Hi, I'm adding an ImageButton as a child to a custom web control and attaching an event handler to it. When the page posts back the event is not being fired however. I initially assumed I had...
2
by: DC | last post by:
Hi, why does this not work: <asp:ImageButton id="myButt" runat="server" OnCommand="myButt_kick" ImageUrl="<% =GetMyButtUrl() %>" </asp:ImageButton>
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.