Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ImageButton ?

Reply
Thread Tools

ImageButton ?

 
 
TM
Guest
Posts: n/a
 
      04-22-2004
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


 
Reply With Quote
 
 
 
 
Dan
Guest
Posts: n/a
 
      04-22-2004
Hover over the broken image, right click and select Properties. Then check
the image path it shows...

"TM" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
=?Utf-8?B?QmluIFNvbmcsIE1DUA==?=
Guest
Posts: n/a
 
      04-22-2004
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



 
Reply With Quote
 
TM
Guest
Posts: n/a
 
      04-23-2004
Bin,

Thanks. It works now.

Thomas


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Datagrid + ImageButton = Slooooowwwww Jake ASP .Net 2 08-04-2003 03:15 PM
Imagebutton over a little text Edmilson ASP .Net 1 07-30-2003 06:22 PM
How can I put some text on a imageButton Matthew ASP .Net 2 07-09-2003 12:23 PM
image/imagebutton client validation ganesh kolappan ASP .Net 2 07-03-2003 06:56 PM
Prevent Postback with ImageButton Marcelo ASP .Net 3 07-01-2003 07:13 PM



Advertisments