By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,846 Members | 1,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,846 IT Pros & Developers. It's quick & easy.

Hyperlink mouseover

P: n/a
Mat
How do you modify the color of an hyperlink when your mouse go over it?

<asp:HyperLink
Dec 20 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Mat
Why this does not work?

======

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Me.Hyperlink.Attributes.Add("onmouseover", "ChangeColor()")

End Sub

Private Sub ChangeColor()

Me.Hyperlink.BackColor = Drawing.Color.Yellow

End Sub

======

"Mat" <Ma*******@hotmail.comwrote in message
news:Ti*********************@weber.videotron.net.. .
How do you modify the color of an hyperlink when your mouse go over it?

<asp:HyperLink

Dec 20 '06 #2

P: n/a
Mat
This does not work too, why?

Me.Hyperlink.Attributes.Add("onmouseover", Me.Hyperlink.ForeColor =
Drawing.Color.Black)

"Mat" <Ma*******@hotmail.comwrote in message
news:oJ*********************@weber.videotron.net.. .
Why this does not work?

======

Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Handles Me.Load
Me.Hyperlink.Attributes.Add("onmouseover", "ChangeColor()")

End Sub

Private Sub ChangeColor()

Me.Hyperlink.BackColor = Drawing.Color.Yellow

End Sub

======

"Mat" <Ma*******@hotmail.comwrote in message
news:Ti*********************@weber.videotron.net.. .
>How do you modify the color of an hyperlink when your mouse go over it?

<asp:HyperLink


Dec 20 '06 #3

P: n/a
try css, no code required:

<style>
a:hover {color:red;}
</style>

-- bruce (sqlwork.com)

Mat wrote:
How do you modify the color of an hyperlink when your mouse go over it?

<asp:HyperLink

Dec 20 '06 #4

P: n/a
"Mat" <Ma*******@hotmail.comwrote in message
news:oJ*********************@weber.videotron.net.. .
Why this does not work?
It's important that you understand the disconnected architecture in which
web apps run. Once the server has streamed the markup down to the client in
response to a request, it has no further interaction with it until / unless
the client sends it another request. That is why, for example, the server
has no way of telling if the user closes their browser without logging out
"cleanly", etc...

When you add dynamic HTML attributes to a control (e.g. onclick, onmouseover
etc), you're giving it additional instructions to run in response to certain
events once it has been streamed down to the client. If you want these
instructions to be in the form of a piece of code, then that piece of code
also has to be streamed down to the client in the form of client-side
scripting, typically JavaScript.

The reason that your code isn't working is because when you hover your mouse
over the hyperlink, it's trying to run a client-side function called
ChangeColor() - however, there is no client-side script function called
ChangeColor because you have written it in server-side VB.NET...

As Bruce has said, for your particular requirement there is actual need to
use DHTML, as everything you require can be achieved with CSS.
Dec 20 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.