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.
<July 2009>
SMTWTFS
2829301234
567891011
12131415161718
19202122232425
2627282930311
2345678

Comment Stats

DayTotal% of Total
Sunday 2046.9%
Monday 42314.3%
Tuesday 50116.9%
Wednesday 54518.4%
Thursday 57219.3%
Friday 53618.1%
Saturday 1856.2%
Total 2966100.0%

Hour1Total% of Total
12:00 AM 752.5%
1:00 AM 802.7%
2:00 AM 672.3%
3:00 AM 812.7%
4:00 AM 642.2%
5:00 AM 1234.1%
6:00 AM 1153.9%
7:00 AM 1755.9%
8:00 AM 1876.3%
9:00 AM 1565.3%
10:00 AM 1866.3%
11:00 AM 1926.5%
12:00 PM 1996.7%
1:00 PM 1846.2%
2:00 PM 1675.6%
3:00 PM 1344.5%
4:00 PM 1153.9%
5:00 PM 1063.6%
6:00 PM 993.3%
7:00 PM 1063.6%
8:00 PM 903.0%
9:00 PM 842.8%
10:00 PM 893.0%
11:00 PM 923.1%
Total 2966100.0%

Comments by Blog Entry Date/Time

Day Entry MadeAvg.Total
Sunday 4.91157
Monday 4.92379
Tuesday 4.21471
Wednesday 7.42668
Thursday 6.53666
Friday 5.17450
Saturday 4.73175
Total 5.522966

Hour1 Entry MadeAvg.Total
12:00 AM 5.2937
1:00 AM 1.002
5:00 AM 0.000
7:00 AM 4.0048
8:00 AM 4.29133
9:00 AM 6.04290
10:00 AM 5.83274
11:00 AM 4.36192
12:00 PM 6.44348
1:00 PM 3.14132
2:00 PM 5.04227
3:00 PM 7.97303
4:00 PM 3.8199
5:00 PM 6.00168
6:00 PM 4.56114
7:00 PM 8.95188
8:00 PM 8.58163
9:00 PM 5.00115
10:00 PM 6.31101
11:00 PM 4.5732
Total 5.522966

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


Blog Stats

Favorite Web Sites

My Books

My MSDN Articles