Archive for October 2006

Update: Dynamically Adding JavaScript To Select ASP.NET Content Pages / Master Pages Via The HtmlGenericControl Class

In a previous article, I had discussed the problem of applying JavaScript to only select content pages of a site that uses master pages.

I said there were four ways to go about it: Simply dumping your JavaScript on your content page (bad practice); add the JavaScript directly to the <head> section of your master page (bad practice); include an external JavaScript file to a <script> tag in your master page’s <head> section (good practice, but wasteful if you only need the script on a single page or few pages of a multi-page site); or use a ContentPlaceHolder in the <head> section, then use a Content tag on the content page to include your JavaScript (which the IDE hates, but will tolerate; and, which Microsoft does not specifically state is an OK practice).

I’ve done some follow-up research and found the right way to include JavaScript on a single page of an ASP.NET site that uses master pages: The HtmlGenericControl class.

Continue reading ‘Update: Dynamically Adding JavaScript To Select ASP.NET Content Pages / Master Pages Via The HtmlGenericControl Class’ »

Monday Night Football Crew: Just Plain Awful, And It’s ESPN’s Own Fault

This excerpt comes from Jason Cole of Yahoo! Sports:

Memo to ESPN: Former NBA star and TNT analyst Charles Barkley is a better color analyst than either Tony Kornheiser or Joe Theismann. Barkley was personable, funny, wry and actually made a few decent points during his cameo appearance on Monday Night Football when Chicago played at Arizona.

Which jogged me to reply, and since I can’t be certain he’ll publish my opinion, here it is for the world to see:

Couldn’t agree with you more that Tony Kornheiser and Joe Theismann are just … plain … awful.

Continue reading ‘Monday Night Football Crew: Just Plain Awful, And It’s ESPN’s Own Fault’ »

Free Weather On Your Website Via The National Weather Service’s RSS Feeds

A lot of Web sites like to offer current weather observations, and there are several providers out there that will either give you a free, pre-sized box for that contains that information — provided you let them splash their logo all over it and link the image back to them, driving traffic away from your site — or charge you a premium for the information.

But the U.S. government provides this information for you, free of charge, via XML and RSS. That’s right: No matter where you are in the United States, with a little bit of programming, you can make your own current observations weather box, free of charge, and customize it to look exactly how you want it to look.

Continue reading ‘Free Weather On Your Website Via The National Weather Service’s RSS Feeds’ »

Dynamically Adding JavaScript onLoad Event-Driven Scripts To ASP.NET 2.0 Templated / Master Page Content Pages

I absolutely adore the master pages feature in ASP.NET 2.0, which is basically a very advanced templating system.

But one of the biggest problems with master pages is that occasionally, you need to add JavaScript to just one or two pages, not every page that is subject to a master page / template. Even worse, some scripts need to fire on the onLoad event — and since it’s the master page, and not the content page, that contains the body tag, you need to somehow raise that event in the master page, from the content page.

I ran into this problem a few weeks ago when working on the MELMAC Education Foundation’s Web site, which uses the Google Maps API to provide a map and point-to-point driving directions.

It took me a while to resolve the issue, since it actually involved two seperate problems: How to implement the JavaScript on the page, and how to trigger the onLoad event, since with master pages, the tag isn’t in the content page itself.

Having found the answers, I thought I’d be a good netizen and share them with you.

Continue reading ‘Dynamically Adding JavaScript onLoad Event-Driven Scripts To ASP.NET 2.0 Templated / Master Page Content Pages’ »