473,654 Members | 2,974 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ASP.NET ImageButton and OnMouseOver

Jay
I have an imagebutton like so:

<asp:ImageButto n onmouseover="th is.src='lc.gif' ;"
onmouseout="thi s.src='nc.gif'; " id="ImageButton 1"
runat="server" ImageUrl="nc.gi f"
AlternateText=" AGR"></asp:ImageButton >

The ImageButton1_Cl ick event is like so:

Private Sub ImageButton1_Cl ick(ByVal sender As System.Object, ByVal e As
System.Web.UI.I mageClickEventA rgs) Handles ImageButton1.Cl ick
ImageButton1.Im ageUrl = "dc.gif"
ImageButton1.Al ternateText &= " 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 2781
Cor
Hi Jay,
I think on this way,
\\\\\\\\\\\\\
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
Me.ImageButton1 .Attributes("on mouseover") = "this.src='lc.g if';"
Me.ImageButton1 .Attributes("on mouseout") = "this.src='nc.g if';"
End Sub

Private Sub ImageButton1_Cl ick(ByVal sender As Object, ByVal e As
System.Web.UI.I mageClickEventA rgs) Handles ImageButton1.Cl ick
Me.ImageButton1 .Attributes("on mouseover") = "this.src='dc.g if';"
Me.ImageButton1 .Attributes("on mouseout") = "this.src='dc.g if';"
End Sub
////////////
I hope this helps?
Cor
Nov 17 '05 #2
Hi Jay,

You'll have to dynamically add the attributes.
ImageButton1.At tributes.Add("O nMouseOver","th is.src='lc.gif' ;) and what not.
Remove those attributes on the Click event like so:
ImageButton1.At tributes("OnMou seOver") = ""

Alex Papadimoulis

"Jay" <msnews.microso ft.com> wrote in message
news:uM******** ******@TK2MSFTN GP09.phx.gbl...
I have an imagebutton like so:

<asp:ImageButto n onmouseover="th is.src='lc.gif' ;"
onmouseout="thi s.src='nc.gif'; " id="ImageButton 1"
runat="server" ImageUrl="nc.gi f"
AlternateText=" AGR"></asp:ImageButton >

The ImageButton1_Cl ick event is like so:

Private Sub ImageButton1_Cl ick(ByVal sender As System.Object, ByVal e As
System.Web.UI.I mageClickEventA rgs) Handles ImageButton1.Cl ick
ImageButton1.Im ageUrl = "dc.gif"
ImageButton1.Al ternateText &= " 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
3294
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."+ JR.Core.Data.JobseekerData.FLD_SEARCH_ID) %>_<%# DataBinder.Eval(Container,"DataItem."+JR.Core.Data.JobseekerData.FLD_SEARCH_ PROFILE_ID ) %>' CommandName='ProfileMatch' id="match" onmouseover="this.src ='../Images/magnifyover.gif'"
2
529
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" AlternateText="AGR"></asp:ImageButton> The ImageButton1_Click event is like so: Private Sub ImageButton1_Click(ByVal sender As System.Object, ByVal e As
2
3635
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 am trying to do. The ImageButton that is on the form handles its Command event just fine, but the ImageButton that is added to the cell does not handle the event. Am I doing something wrong, or is not possible to add server controls to a calendar...
3
1568
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%>'" onmouseout="this.src='<%=MyImage1%>'" runat="server" ImageAlign="Left" ImageUrl="<%=MyImage1%>"> </asp:ImageButton>
2
1549
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'" ImageUrl="images/button_search_n.gif" name="btSimpleSearch" width="74" height="21" border="0"></asp:ImageButton> Then i declare it at the top of the class file protected System.Web.UI.WebControls.ImageButton btSimpleSearch; then i wire up the event
6
22120
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 I want to know how can I have the mousedown and mouseup buttons events. I think that I have to do this in JavaScript. Can you help me on this?
2
17731
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 out how to make my image buttons come 'alive' with a mouseover effect. I am used to DHTML and using the mouseover event to change the bitmap. But what is the correct/best way to do this in ASP.NET ? Any experienced ASP.NET people who would care to...
1
1283
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 I've done it done it that way using javascirpt in the html code: ----------------------------------------------------- <a id="A1" href="#"
6
8302
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()" onMouseOver="MM_swapImage('go','','images/go_on.gif',1)" ID="headerSearchButton" runat="server" Width="27" Height="20" ImageUrl="http://localhost/App1/images/go_off.gif"></asp:ImageButton> the onMouseOver/Out both have the squiggly lines under them in VS
0
8290
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8815
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8482
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8593
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7306
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6161
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4149
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2714
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1916
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.