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   

My Links

Ads Via DevMavens

Archives

Post Categories

 

I am a Microsoft MVP for ASP.NET.
I am an ASPInsider.
<March 2010>
SMTWTFS
28123456
78910111213
14151617181920
21222324252627
28293031123
45678910

Comment Stats

DayTotal% of Total
Sunday 2056.8%
Monday 42514.1%
Tuesday 51917.2%
Wednesday 55618.4%
Thursday 58019.2%
Friday 54718.1%
Saturday 1886.2%
Total 3020100.0%

Hour1Total% of Total
12:00 AM 782.6%
1:00 AM 812.7%
2:00 AM 682.3%
3:00 AM 822.7%
4:00 AM 692.3%
5:00 AM 1264.2%
6:00 AM 1193.9%
7:00 AM 1816.0%
8:00 AM 1926.4%
9:00 AM 1585.2%
10:00 AM 1886.2%
11:00 AM 1936.4%
12:00 PM 2016.7%
1:00 PM 1846.1%
2:00 PM 1695.6%
3:00 PM 1354.5%
4:00 PM 1153.8%
5:00 PM 1073.5%
6:00 PM 1013.3%
7:00 PM 1073.5%
8:00 PM 923.0%
9:00 PM 882.9%
10:00 PM 913.0%
11:00 PM 953.1%
Total 3020100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 5.00160
Monday 4.80384
Tuesday 4.04477
Wednesday 7.39680
Thursday 6.26676
Friday 5.07466
Saturday 4.78177
Total 5.403020

Hour1 Entry MadeAvg.Total
12:00 AM 5.2937
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 3.8550
8:00 AM 3.72134
9:00 AM 6.06297
10:00 AM 5.63276
11:00 AM 4.22194
12:00 PM 6.16351
1:00 PM 3.09133
2:00 PM 4.89230
3:00 PM 7.67322
4:00 PM 4.00108
5:00 PM 6.07170
6:00 PM 4.64116
7:00 PM 8.95188
8:00 PM 8.63164
9:00 PM 5.00115
10:00 PM 6.31101
11:00 PM 4.5732
Total 5.403020

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


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles