A few thoughts on jQuery templating with jQuery.tmpl

General, JavaScript, jQuery, UI By . Updated November 8, 2010

I spent some quality time with Dave Reed’s latest revision of John Resig’s jQuery.tmpl plugin recently, migrating a small project from jTemplates. Since both the jQuery team and Microsoft team have requested feedback on jQuery.tmpl, I decided to write about my experience using it (as I am wont to do with these templating proposals).

Overall, jQuery.tmpl is a great step in the right direction. It’s small, it’s simple, and it’s fast. Overloading append() to allow the append(Template, Data) syntax is phenomenal. That approach feels more like idiomatic jQuery than anything else I’ve used, including jTemplates.

However, if this template rendering engine is going to succeed broadly, I feel there’s one important feature still missing. Additionally, there are a couple ancillary features that are present in the current proposal, but should be protected.

Click here to read the rest of this post »

How 30 seconds dropped my bounce rate by 78%

General By . Posted April 23, 2010

Blogging about blogging alert!

This post is a bit off-topic, but I thought it was interesting. Since many of you have asked me metablogging questions, I thought you might be interested too.

An overwhelming majority of people who end up on my site only view a single page per visit. In fact, you’ll probably do the same. As I’ve come to realize: that’s okay.

I didn’t always think it was okay though. Throughout most of 2007, that caused me a great deal of concern. I’d been reading too many blogs about blogging, was convinced that persuading you to click through multiple pages was essential to the site’s success, but wasn’t able to make that happen here

Ultimately, the number of pageviews wasn’t very worrisome, because the site continued to grow. What did frustrate me was the impact that single-view visits have on a more important metric.

Click here to read the rest of this post »

PostBack Ritalin v1.1 – Updated for ASP.NET 4

PostBack Ritalin By . Posted April 12, 2010

Firebug displaying SenderString is undefined when using PostBack Ritalin with ASP.NET 4

As you might notice soon enough, a change in ASP.NET 4’s client-side API breaks versions 0.8 through 1.0 of PostBack Ritalin. Using those older versions of the control with ASP.NET 4 will throw a JavaScript error during BeginRequest and break asynchronous postbacks as a result.

PostBack Ritalin v1.1 works around that issue, and is also backward-compatible with ASP.NET 2.0 and 3.5. It’s available on the PostBack Ritalin project page now.

Special thanks to Maciej Borzecki for reporting the issue to me early enough to have a fix ready today.

5 Steps Toward jQuery Mastery

JavaScript, jQuery By . Posted March 30, 2010

I am plagiarizing myself!

I originally wrote this article for my friend Moses (of Egypt) to be published in the .Network magazine’s inaugural issue, which coincided with this year’s Cairo Code Camp. Since the article turned out well and there was no corresponding online version, we agreed it would be a good idea to republish it online here too.

Most of us get our first taste of jQuery by implementing a simple animation effect or using a plugin for a specific purpose. This is natural because, like JavaScript itself, jQuery lends itself to beginning with the basics and building from there.

As you branch out from the trivial and begin using jQuery for more complex solutions, it’s important that you stay vigilant for new ways to approach those more involved problems. What works well enough for a dozen lines of code may not work for hundreds, and the unforgiving cross-platform environment that comes along with developing for web browsers only magnifies any trouble you run into.

With that in mind, I want to share a few tips with you that I found valuable as my work with jQuery became more complex.

Click here to read the rest of this post »

ASMX ScriptService mistake: Installation and configuration

AJAX, ASMX Mistakes and Misconceptions, ASP.NET By . Updated April 4, 2011

Continuing my series of posts about ASMX services and JSON, in this post I’m going to cover two common mistakes that plague the process of getting a project’s first ASMX ScriptService working: Installing System.Web.Extensions into the GAC and configuring your web.config.

Click here to read the rest of this post »

ASMX and JSON – Common mistakes and misconceptions

AJAX, ASMX Mistakes and Misconceptions, ASP.NET By . Posted March 3, 2010

While we were recording episode 5 of Mastering jQuery, I found myself running down a lengthy list of misconceptions and potential pitfalls when it comes to using ASMX services for AJAX callbacks. After years of fielding questions revolving around that topic, I suppose I’ve developed a decent handle on the issues most often encountered.

To preemptively surface some of that commonly requested information, I’m going to publish a series of relatively short posts, each describing one mistake or misconception that I’ve seen come up frequently.

To get started, I want to cover one of the most fundamental of these misconceptions: That ASMX services can’t return JSON.

Click here to read the rest of this post »

How you can force the Ajax Script Loader to use jQuery 1.4

AJAX, ASP.NET, JavaScript, jQuery By . Updated February 1, 2010

If you’ve already begun using Microsoft’s new Ajax Script Loader with a CDN-hosted version of jQuery, today’s release of jQuery 1.4 may have left you wondering how to upgrade. Personally, I didn’t want to wait on a new version of Start.js, nor did I want to abandon the script loader now that I’ve become accustomed to its benefits.

No doubt, an upcoming ASP.NET Ajax Library iteration will update Start.js’ jQuery definition to reference jQuery 1.4.x. Regardless, knowing how to patch the script loader on your own terms is something that will be of recurring usefulness.

Luckily, the script loader is open and extensible enough that it’s possible to change which script versions are used. So, I want to briefly show you how the script loader defines JavaScript includes and how you can patch those definitions without modifying Start.js itself.

Click here to read the rest of this post »

3 years of Encosia, the best of 2009, and my gratitude

General By . Updated January 14, 2010

On this day in 2006, I wrote and published a short post here about something that had eluded my attempts at searching for an answer. I thought that archiving the information online might help if I needed to find it again later, and that it might help anyone else who had been similarly unable to track down the answer.

Three years later, the site has served over one million page views to JavaScript enabled browsers in the last year alone, and thousands of you keep tabs on the site’s updates through RSS, email, and/or Twitter.

One step at a time, it’s astonishing just how far this thing has come.

Click here to read the rest of this post »

Mastering jQuery now available at TekPub

AJAX, ASP.NET, JavaScript, jQuery By . Updated September 1, 2010

Mastering jQuery

If you haven’t been following the progress of Rob Conery and James Avery’s new venture, TekPub, you’ve been missing out on some great instructional videos. I especially like that they trend slightly Alt.NET, giving you more balanced information than is sometimes available from “official” .NET screencasts.

For the past few weeks, I’ve been working with James to record a series of episodes for TekPub myself: Mastering jQuery.

Mastering jQuery walks through the basics of using jQuery, the revolutionary JavaScript framework that makes writing client-side code fun and easy, and then dives into the details of writing AJAX enabled ASP.NET MVC and ASP.NET Web Forms applications. We will also cover popular plugins and extending jQuery in future episodes.

Today, the first video in that series is available: Getting Started with jQuery.

In this episode we cover the basics of getting started with jQuery. We start with a basic HTML page and show how to include jQuery, how to write your first code, and explain all of the moving pieces and how they work.

If you’ve been following my site and working with jQuery already, the first episode may sound elementary, but there’s going to be something for everyone before the series is finished. By the third episode, we’re already into topics like making AJAX calls to MVC controller actions and progressively enhancing an entry form with the jQuery form plugin.

I hope you’ll head over to TekPub, and have a look for yourself.

Emulate ASP.NET validation groups with jQuery validation

AJAX, ASP.NET, JavaScript, jQuery, UI By . Updated August 5, 2011

In my most recent post, I demonstrated a workaround to allow using the jQuery validation plugin with WebForms pages. The basic idea was to trigger validation only on submissions that occurred within a single logical form, instead of catching submissions anywhere on WebForms’ all-encompassing physical form.

This approach worked fine for a single logical form, but wasn’t robust enough when handling validation for multiple logical forms on a single page. Additionally, it did not properly handle the enter key, allowing users to (perhaps accidentally) slip past validation if they simply hit the enter key within a TextBox.

In this post, we will continue by refining the solution from last time. So, if you haven’t read the previous post, familiarize yourself with it first. Specifically, this post will cover how to implement an analogue of WebForms’ ValidationGroup, use that to independently validate multiple form regions, handle the enter key, and refactor the final solution to minimize duplicated code.

Click here to read the rest of this post »