Scott on Writing

Musings on technical writing...

skmLinkButton - Easily Displaying Text in the Browser's Status Bar

I was perusing the microsoft.public.dotnet.framework.aspnet.webcontrols newsgroup yesterday and stumbled upon this question by Brian Hoops:

Is there a way within asp to modify what the status bar text reads when the user hovers above the text for a link-button.

IE: http://www.sitename.com/pagename.aspx rather than javascript:__doPostBack(...)

or do I need to have a javascript onmouseover for every one?

I responded to Brian's question, informing him that there were no built-in properties of the LinkButton Web control that would provide this functionality, and that adding said functionality could be accomplished in one of two ways:

  1. By manually entering the needed JavaScript into the LinkButton's declarative syntax, or programmatically through the LinkButton's Attributes collection, or
  2. By creating a new custom control that derived from LinkButton and included a property like StatusBarText, that could be set to the text to display in the browser's status bar. This extended control, then, would inject the necessary JavaScript.

For the heck of it I whipped up a custom control called skmLinkButton that extended the LinkButton class and provided the desired behavior. (Additionally, skmLinkButton includes the ability to add a confirm dialog box, similar to Andy Smith's ConfirmedButtons set of controls.)

skmLinkButton, along with my other open-source ASP.NET server controls, is listed on my Code Projects page.

posted on Thursday, October 21, 2004 10:36 AM

Feedback

# re: skmLinkButton - Easily Displaying Text in the Browser's Status Bar 10/22/2004 6:07 AM Dimitri Glazkov

You could also register a start-up script like this (typing without testing, so consider it a pseudocode):

var anchors = document.getElementsByTagName("A");
for(var i = 0; i < anchors.length; i++)
{
if (a.href.indexOf("javascript:__doPostBack") == 0)
{
a.onmouseover = function()
{
status = a.innerText;
}
a.onmouseout = function()
{
status = defaultStatus;
}
}
}

# re: skmLinkButton - Easily Displaying Text in the Browser's Status Bar 10/22/2004 6:09 AM Dimitri Glazkov

Shoot. Just after the for loop declaration, add "a = anchors[i]".

# Excellent tool! 10/22/2004 7:28 AM BigJim in STL

Scott

Thanks again for another excellent tool / tutorial! I tried this and it works very nicely. One question, though. I tried the "Live Demo" in IE and it worked fine. But in Firefox, it doesn't cause anything to appear. Any ideas?

# re: skmLinkButton - Easily Displaying Text in the Browser's Status Bar 10/22/2004 8:08 AM Scott Mitchell

Dimitri, what version of FireFox are you using? I'm using 0.9.3 and it works fine for me. What, specifically, is not working? If I move my mouse over the "My Blog" link I see, in the status bar, "Visit ScottOnWriting.NET!" Does this not work for you?

# re: skmLinkButton - Easily Displaying Text in the Browser's Status Bar 10/22/2004 2:39 PM Scott Mitchell

It appears that the FireFox 1.0 PR release by default disables client-side script for mucking with the browser's status bar text. You can override this behavior, though, by entering
about:config in Mozilla's address bar and changing the dom.disable_window_status_change setting to false.

# re: skmLinkButton - Easily Displaying Text in the Browser's Status Bar 10/23/2004 5:40 AM Dimitri Glazkov

.. and where oh where are the hordes of browser-bashes, pointing out how wrong it is to change a well-established behavior and urging to switch to another flavor? Oh, wait, this only happens to Internet Explorer...

# re: skmLinkButton - Easily Displaying Text in the Browser's Status Bar 10/23/2004 11:11 PM Armando Andrade

Very nice control Scott, i look at the code and is really clean and straightforward... i would like to make a review of your control in a spanish site, could i do this?

# re: skmLinkButton - Easily Displaying Text in the Browser's Status Bar 11/22/2004 8:45 AM mofaha

Your article answered a fairly unconnected question that I had regarding the failure of window.defaultStatus in Firefox 1.0 PR. I found your article via Google. Thanks, you saved me some time.

# re: skmLinkButton - Easily Displaying Text in the Browser's Status Bar 12/4/2004 8:17 PM Ryan Anderson

Scottie Doo!
I am continually schooled by your programming and I love it. I have a question. Why would you use a "Virtual Function" for the EscapeJavaScript method? This is the first time I have seen a "virtual" and when attempting to research what, how, and why I stumled onto MSDN article that stated, "One conclusion you can draw is that Virtual Function calls are about two times as expensive as regular calls when you're calling a method in a class. Bear in mind that calls are cheap to begin with, so I wouldn't remove all virtual calls. You should always use virtual methods when it makes sense to do so. "

Why does it make sense here, and would it be maditory for getting the functionality to desire?

Many thanks! Keep on writting!

# re: skmLinkButton - Easily Displaying Text in the Browser's Status Bar 12/4/2004 8:29 PM Ryan Anderson

So this is what I found.
1. No Difference.
2. A virtaul function can be overriden but an abstract cannot be overriden.
3. A virtual function has a body but abstract function does not have any.
4. A abstract function can be overriden but an virtual function cannot be overriden.

But I am still uncertain why the usage here.
TY!

# Enhancements to skmLinkButton 8/24/2005 12:45 AM Scott on Writing

Title:  
Name:  
Url:
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments   

Add To Your Reader

My Links

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<May 2008>
SMTWTFS
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567

Comment Stats

DayTotal% of Total
Sunday 1866.8%
Monday 37913.9%
Tuesday 45316.7%
Wednesday 50418.5%
Thursday 53519.7%
Friday 49418.2%
Saturday 1666.1%
Total 2717100.0%

Hour1Total% of Total
12:00 AM 652.4%
1:00 AM 682.5%
2:00 AM 622.3%
3:00 AM 742.7%
4:00 AM 572.1%
5:00 AM 1033.8%
6:00 AM 1084.0%
7:00 AM 1585.8%
8:00 AM 1716.3%
9:00 AM 1475.4%
10:00 AM 1716.3%
11:00 AM 1816.7%
12:00 PM 1886.9%
1:00 PM 1696.2%
2:00 PM 1605.9%
3:00 PM 1324.9%
4:00 PM 1073.9%
5:00 PM 923.4%
6:00 PM 913.3%
7:00 PM 963.5%
8:00 PM 833.1%
9:00 PM 782.9%
10:00 PM 792.9%
11:00 PM 772.8%
Total 2717100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.54144
Monday 5.22339
Tuesday 4.28419
Wednesday 7.67637
Thursday 6.90607
Friday 5.48411
Saturday 5.33160
Total 5.842717

Hour1 Entry MadeAvg.Total
12:00 AM 5.0035
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 7.0035
8:00 AM 5.35107
9:00 AM 6.32278
10:00 AM 6.47246
11:00 AM 4.41181
12:00 PM 6.88330
1:00 PM 3.00111
2:00 PM 5.41222
3:00 PM 8.64285
4:00 PM 4.0589
5:00 PM 5.92154
6:00 PM 4.52113
7:00 PM 9.67174
8:00 PM 9.80147
9:00 PM 5.05111
10:00 PM 5.4265
11:00 PM 4.5732
Total 5.842717

Learn More About Comment Stats
1 - All times GMT -8...


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles