Once you start the page, it should similar to the following screen capture. Your results may vary based on any CSS files linked to your page.
If you now hover the mouse cursor over the "Test this link" hyperlink, you'll see the following--pay close attention to the status bar--this is the whole point of the exercise…
Notice that the status bar shows "mouseover" as its message, which is what we coded for the mouseover event in Listing 1.
Remember, this is a standard HTML anchor element, added directly with an <a> tag. The next behavior I introduce is very important. Now just hold down the left mouse button, but do not let it up!
You'll now see the status bar change to show the following message:
Hmm! Note that in our code (Listing 1 above) we put in an override for the mousedown event. But we are seeing the value of the href parameter, not our mousedown text. What gives? Wait! It gets more interesting. Now, without letting up the left mouse button, move your cursor off the link. Hover your cursor above the link, and again press and hold the left mouse button (don't let it up yet!). All of a sudden we see something different!
Hmm! This is the actual status message that we wanted to have. So why isn't it showing up the first time? Well, the short answer is, I don't know. I do know that every other site where I have tried the same experiment provides the same behavior. My guess is there is some initialization going on with the DOM that we don't have access to (or to which I can't find documentation) that sets the mousedown status message to the value of the href parameter, and it doesn't get overridden until after the first onmousedown event is processed. So this is the big limitation in this, and apparently every, override of an anchor. If it can't be gotten around in JavaScript or HTML, it can't be gotten around in the code-behind.
So, with that limitation, play with the remainder. Hover over the standard LinkButton and see the onerous javascript message. We didn't override this one in any way, so pressing the mouse buttons doesn't change anything. Similarly, we didn't override the heading for col3 in the DataGrid. But we did override the heading link button for col1 and col2. If you hover over them, hold the left mouse button down, move the cursor away, and so on, you'll see the same behavior as the standard link. First mousedown without letting the button up gives the standard message, and subsequent mousedowns provide our intended message.
Now, finally, actually click on col1 or col2. Note that I'm not sorting in my code. But the page is performing a post back, and is returning a response regarding which action you've requested. Now examine the behavior of the link buttons again. We see the old behavior. First mousedown shows the vicious, nasty, heinous JavaScript status message. So, anytime the page loads, whether from a postback or not, this mousedown text is being set initially to the value of the href parameter. Furthermore, my JavaScript book states that the link object does not process the onmousedown event--only the onclick event. In some respects, this solution shouldn't even work, and we should be modifying the onclick event, or somehow munging the href parameter. But getting it to postback with the right control ID information would then be a complicated matter.