How to rotate JavaScript ads during ASP.NET AJAX requests

AJAX, ASP.NET, JavaScript, UI By Dave Ward on January 4th, 2009

A common question that I find myself fielding lately is how to handle the problem of rotating JavaScript based advertisements. As AJAX becomes ubiquitous on ad supported sites, we must take care that decreasing page views don’t also mean proportionally decreasing revenues.

Many find their way to ScriptManager.RegisterStartupScript, use that to re-inject the script during a partial postback, and expect that doing so will refresh the ad. Unfortunately, that doesn’t work when dealing with JavaScript based ads such as Google’s AdSense.

In this post, I’m going to show you why RegisterStartupScript does not solve the problem, the alternative that I suggest, and how to use that method to also defer loading of advertisements until after your content.

Click here to read the rest of this post »

3 reasons why you should let Google host jQuery for you

AJAX, JavaScript, Performance, jQuery By Dave Ward on December 10th, 2008

All too often, I find code similar to this when inspecting the source for public websites that use jQuery:

<script type="text/javascript" src="/js/jQuery.min.js"></script>

If you’re doing this on a public facing* website, you are doing it wrong.

Instead, I urge you to use the Google AJAX Libraries content delivery network to serve jQuery to your users directly from Google’s network of datacenters. Doing so has several advantages over hosting jQuery on your server(s): decreased latency, increased parallelism, and better caching.

In this post, I will expand upon those three benefits of Google’s CDN and show you a couple examples of how you can make use of the service.

Update (11/6/09): Since you’re reading this post, you may also be interested to know that Google also hosts full jQuery UI themes on the AJAX APIs CDN.

Click here to read the rest of this post »

Have you ever wondered why CodePlex is so slow?

AJAX, ASP.NET, Performance By Dave Ward on December 3rd, 2008

It’s hard to believe that nearly two months have already passed since opening the doors on the Username Availability Validator project. I made a few mistakes in how I ran the project, but I’m happy with the overall outcome.

However, one thing that disappointed me throughout the entire contest was how slow CodePlex can be. Even as the single person most invested in the success of the project, I often found myself leaving the site in the middle of tasks, unwilling to endure the slowness. What’s worse, I also found myself procrastinating to avoid returning to CodePlex and dealing with these waits.

I’m not one to complain without offering some constructive criticism though. Especially since we’re talking about a completely free service.

I think the lesson to be learned here is something that many ASP.NET developers could benefit from. So, I’d like to take a look at one ASP.NET AJAX related inefficiency that I found on CodePlex and one potential alternative to it.

Click here to read the rest of this post »

Use jQuery and quickSearch to interactively search any data

AJAX, ASP.NET, UI, jQuery By Dave Ward on October 31st, 2008

While reviewing my latest post’s outbound click-through stats, I noticed that most of you found Rik LomasquickSearch more interesting than the rest. In light of that interest, I’ve decided to show you an example of how you might implement its functionality in conjunction with ASP.NET.

For this demonstration, I’m going to use Delicious as a source of sample data to apply the technique to. I’m sure you’re getting tired of my RSS feed as demo data, and the Delicious API provides an abundance of topical data via jQuery tag feeds.

In this post I will show you how to use LINQ to XML to query the Delicious API, display that data in a table, apply the quickSearch plugin to that table, work around a problem that arises when using quickSearch with ASP.NET, and lay the groundwork for a “no results” state.

Click here to read the rest of this post »

7 of my favorite jQuery plugins for use with ASP.NET

AJAX, ASP.NET, UI, jQuery By Dave Ward on October 19th, 2008

One of jQuery’s greatest strengths is its thriving plugin ecosystem. Hundreds of plugins are available at plugins.jquery.com alone, with even more hosted on author sites. If you think of a feature, chances are there’s a jQuery plugin to implement it in just a few lines of code (if that).

Having used jQuery with ASP.NET for over a year now, I’ve discovered that some plugins are more easily combined with ASP.NET than others. In fact, one popular plugin even fails completely when used with ASP.NET AJAX.

Without further ado, here are seven of my favorites. I couldn’t begin to rank them preferentially, so I ordered them by how long I’ve been using them with ASP.NET.

Click here to read the rest of this post »

Using jQuery to display a modal UpdatePanel confirmation

AJAX, ASP.NET, UI, jQuery By Dave Ward on October 11th, 2008

A screenshot of the modal confirmation dialogAfter the previous example of integrating jQuery and ASP.NET AJAX to display modal progress indication, there were requests that I follow it up with an example of also displaying the confirmation modally. So, I’m going to expand the original post with a technique for doing exactly that.

If you missed my first post on the topic, do be sure to read it first. Otherwise, this continuation may be difficult to follow.

Click here to read the rest of this post »

Alt.NET Podcast – jQuery in ASP.NET

AJAX, ASP.NET, JavaScript, jQuery By Dave Ward on October 10th, 2008

If you’re reading this, you probably already know that I’m a big fan of integrating jQuery with ASP.NET. If you’re of the same mind, you’re sure to enjoy the latest Alt.NET Podcast: jQuery in ASP.NET.

Update: Part two of our discussion on jQuery and ASP.NET.

Mike Moore hosted a roundtable discussion on the topic, between Bertrand Le Roy, Chris Brandsma, Rick Strahl, Steven Harman, Scott Koon, and myself. Between us all, the discussion ranges from the official Microsoft viewpoint, to theory about JavaScript and jQuery, to the pragmatic.

Whether you’re already on board with jQuery + ASP.NET integration or you’re still trying to figure out what the announcement means for you, I think you’ll find the discussion interesting. I know I did!

Using jQuery to enhance ASP.NET AJAX progress indication

AJAX, ASP.NET, UI, jQuery By Dave Ward on October 4th, 2008

Animated example of using jQuery's BlockUI with an UpdatePanelIn the spirit of Microsoft’s official embrace of jQuery last week, I’d like to show you an example of how easily you can add jQuery functionality to existing ASP.NET AJAX applications. jQuery allows you to achieve exceptional results with minimal difficulty, and integrating it with ASP.NET is not an exception.

My previous posts about jQuery have been somewhat lower level, incorporating JSON, web services, and the like. While these are important tools to have at your disposal, the realities of software development sometimes leave us scrambling for something quick and dirty.

In those situations, you may find yourself using the UpdatePanel.

To that end, I’m going to show you how easily you can use jQuery’s BlockUI plugin to display a modal progress indicator during an UpdatePanel’s partial postback.

Click here to read the rest of this post »

Avoid this tricky conflict between ASP.NET AJAX and jQuery

AJAX, ASP.NET, jQuery By Dave Ward on September 28th, 2008

ASP.NET and jQuery's logos togetherYou have probably already read the great news that Microsoft is going to begin shipping jQuery with Visual Studio and ASP.NET MVC. If not, make sure you take a minute to read the official announcements from both ScottGu and John Resig. This represents a surprising, yet tremendously welcomed change of course for Microsoft.

If you haven’t yet used jQuery with ASP.NET, you’re in for a pleasant surprise. It removes almost all of the pain from client-side development. Coming from an ASP.NET centric perspective, you may find several of my previous jQuery articles useful.

Additionally, I highly recommend the articles that Matt Berseth and Rick Strahl have written on the topic of using jQuery with ASP.NET. I am constantly amazed at the quantity and quality of content that they both generate.

Introductions aside, I’d like to take this opportunity to discuss an incompatibility between ASP.NET AJAX and at least one jQuery plugin, which needs to be fixed.

Click here to read the rest of this post »

Username Availability Validator is nearing… availability

AJAX, ASP.NET, General By Dave Ward on September 18th, 2008

After about a week of great discussion and development over at CodePlex, the Username Availability Validator control is nearing readiness for an initial release.

While there are still a few outstanding bug fixes up for grabs and ample room for enhancement, most of the control’s base functionality has been implemented. If you intend to enter the Advanced ASP.NET AJAX Server Controls book giveaway contest via code contribution, time is running out, so don’t delay.

Click here to read the rest of this post »