Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / JScript / September 2003

Tip: Looking for answers? Try searching our database.

ASP.NET ImageButton and OnMouseOver

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jay - 30 Sep 2003 03:50 GMT
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
Cor - 30 Sep 2003 08:29 GMT
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
Alex Papadimoulis - 30 Sep 2003 14:31 GMT
Hi Jay,

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

Alex Papadimoulis

> I have an imagebutton like so:
>
[quoted text clipped - 19 lines]
>
> Jay

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.