473,399 Members | 4,177 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,399 software developers and data experts.

ASP.NET ImageButton and OnMouseOver

Jay
I have an imagebutton like so:

<asp:ImageButton onmouseover="this.src='lc.gif';"
onmouseout="this.src='nc.gif';" id="ImageButton1"
runat="server" ImageUrl="nc.gif"
AlternateText="AGR"></asp:ImageButton>

The ImageButton1_Click event is like so:

Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
ImageButton1.ImageUrl = "dc.gif"
ImageButton1.AlternateText &= " selected"
End Sub
When the mouse is over I need to change the image to lc.gif. When the mouse
is NOT over it should default back to its original image (nc.gif). HOWEVER,
when it is clicked it should go to dc.png. and stay there - no more mouse
over, out, etc. How can this be done.

Thanks a lot.

Jay
Nov 17 '05 #1
2 2767
Cor
Hi Jay,
I think on this way,
\\\\\\\\\\\\\
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Me.ImageButton1.Attributes("onmouseover") = "this.src='lc.gif';"
Me.ImageButton1.Attributes("onmouseout") = "this.src='nc.gif';"
End Sub

Private Sub ImageButton1_Click(ByVal sender As Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
Me.ImageButton1.Attributes("onmouseover") = "this.src='dc.gif';"
Me.ImageButton1.Attributes("onmouseout") = "this.src='dc.gif';"
End Sub
////////////
I hope this helps?
Cor
Nov 17 '05 #2
Hi Jay,

You'll have to dynamically add the attributes.
ImageButton1.Attributes.Add("OnMouseOver","this.sr c='lc.gif';) and what not.
Remove those attributes on the Click event like so:
ImageButton1.Attributes("OnMouseOver") = ""

Alex Papadimoulis

"Jay" <msnews.microsoft.com> wrote in message
news:uM**************@TK2MSFTNGP09.phx.gbl...
I have an imagebutton like so:

<asp:ImageButton onmouseover="this.src='lc.gif';"
onmouseout="this.src='nc.gif';" id="ImageButton1"
runat="server" ImageUrl="nc.gif"
AlternateText="AGR"></asp:ImageButton>

The ImageButton1_Click event is like so:

Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As
System.Web.UI.ImageClickEventArgs) Handles ImageButton1.Click
ImageButton1.ImageUrl = "dc.gif"
ImageButton1.AlternateText &= " selected"
End Sub
When the mouse is over I need to change the image to lc.gif. When the mouse is NOT over it should default back to its original image (nc.gif). HOWEVER, when it is clicked it should go to dc.png. and stay there - no more mouse
over, out, etc. How can this be done.

Thanks a lot.

Jay

Nov 17 '05 #3

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

Similar topics

1
by: Darren Clark | last post by:
I need to be able to send through 2 peices of infomraiton in the commandArgument property of a image button... <asp:imagebutton CommandArgument='<%# DataBinder.Eval(Container,"DataItem."+...
2
by: Jay | last post by:
I have an imagebutton like so: <asp:ImageButton onmouseover="this.src='lc.gif';" onmouseout="this.src='nc.gif';" id="ImageButton1" runat="server" ImageUrl="nc.gif"...
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...
3
by: TM | last post by:
I have this line below coded in the aspx/html at design time: ***************** <TD> <asp:ImageButton id="Imagebutton1" onmouseover="this.src='<%=MyImage2%>'"...
2
by: Darren Clark | last post by:
I have an image button on a page <asp:ImageButton Runat=server ID="btSimpleSearch" onMouseOut="this.src = 'images/button_search_n.gif'" onMouseOver="this.src = 'images/button_search_r.gif'"...
6
by: ruca | last post by:
Hi gurus, I have a imagebutton in my WebForm, and I want that when I click (mouse down) on her the imagebutton change image and when I "unclick" (mouse up) change to the original image. Basically...
2
by: Bendik Engebretsen | last post by:
I'm an ASP newbie and have just started experimenting with ASP.NET 2.0 using the VS.NET 2005 Beta. As a starting point I have used the 'Personal WEB site' starter kit. I am now trying to figure...
1
by: Franck | last post by:
Heelo, I'm looking for a component that allow creating a ImageButton slighlty imporved as I wish It could change backggrtound image with the following event; onMouseOut onMouseOver onClick ...
6
by: simon | last post by:
hello. have an image button that i'd like to add some onMouseOver/Out to an imageButton. line looks like this... <asp:ImageButton onMouseOut="MM_swapImgRestore()"...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.