473,402 Members | 2,046 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,402 software developers and data experts.

Hyperlink mouseover

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

<asp:HyperLink
Dec 20 '06 #1
4 8127
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
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
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: addi | last post by:
All, I have seen the feature on many sites and would like to implement it for myself as well, where if a mouse is moved over a hyperlink, it gets underlined. For example, in my code, if the...
2
by: Peter Eriksson | last post by:
I am making a link with the HyperLink-class like this: HyperLink link = new HyperLink(); link.NavigateUrl = "http://www.page.com"; link.Text = "Some text";...
2
by: wazoo | last post by:
I'm hoping someone here might help me with this. I'm putting the finishing touches on my intranet web app, and I'm adding some simple JavaScript to my VB.Net Webforms. This works:...
1
by: vishal | last post by:
I am using a datagrid where there is a hyperlink column. On mouseover I get the whole link in the status bar which I want to put some static message or mask it. How do I achive this in .net? If...
1
by: mjryan | last post by:
Any idea why this code would not fire? btnMakePmt.Attributes.Add("onMouseOver", "this.src='img\\MakePmt_nav2_over.jpg'") btnMakePmt.Attributes.Add("onMouseOut",...
8
by: Nathan Sokalski | last post by:
I have several System.Web.UI.WebControls.HyperLink Controls which I want to display as rollover images. I know how to make these manually using the <a> and <img> tags or the <a> tag and a...
0
by: Whitney Yiu | last post by:
I am using a DataGrid, and have bound it to some data (not using the quick design way though -- i hard coded it using sql data adapter, command, etc). Anyways, I have a column that is a link, and i...
1
by: Peter Morris | last post by:
Newbie q. how do I change the image url for a hyperlink on mouseover? I have a menubar, and I want to highlight the selected item.
5
by: Dave | last post by:
I've been given a flash banner and told to make it a hyperlink. I tried this: <script type="text/javascript"> Document.getElementById("flashcontent").onclick = function(){...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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,...
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
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,...
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.