Onmouse over

neo_fmu

New Member
I have an image on a page and when the mouse is moved over the image I want another image to be displayed. I used to do it using Javascript Onmouseover method. Is there a way to do the same in ASp.NEt. And can i use javascript within an ASP.NET page???I'm not sure if ASP.NET has a way to do a mouseover effect for you, but if it does it would simply create the client-side JavaScript code that you've written in the past. You can absolutely use JavaScript in an ASP.NET page -- ASP.NET uses it all the time! Validator controls, for example, get their job done by using client-side JavaScript.<BR><BR>So I'd suggest that if you already have the script to do your mouseover effects, keep using it. If someone knows better than this, then I'd be happy to know a better solution as well.I have recently learned of two ways to do this with an ImageButton:<BR><BR>A) In your x.aspx file:<BR>----------------------<BR><BR><asp:ImageButton<BR> id="ImageButton1"<BR> runat="server"<BR> ImageUrl="ImagesImage1.gif"<BR> OnMouseOver="src=http://aspmessageboard.com/archive/index.php/'Images/Image2.gif'"<BR> OnMouseOut="src='Images/Image1.gif'"<BR></asp:ImageButton><BR><BR>B) In your x.aspx.vb file:<BR>-------------------------<BR><BR>Assume that ImageButton1 has its ImageURL property set to "ImagesImage1.gif" (in x.aspx file).<BR><BR>Private Sub Page_Load(...) Handles MyBase.Load<BR> ImageButton1.Attributes.Add("onmouseover", "src='Images/Image2.gif'")<BR> ImageButton1.Attributes.Add("onmouseout", "src='Images/Image1.gif'")<BR>End Sub<BR><BR>Notes:<BR>-----<BR><BR>1) I'm not sure why I needed to reverse the slash, but<BR> if you view the source, you'll see, it reverses them?<BR><BR>2) I'm not sure if this works if other than IE?<BR>I would like to know how to change the image for ImageButton2 via the mouseover/mouseout of ImageButton1?
 
Back
Top