Use jQuery and ASP.NET AJAX to build a client side Repeater

AJAX, ASP.NET, JavaScript, UI, jQuery By Dave Ward on June 26th, 2008

There was some interesting discussion on Matt Berseth’s blog recently, regarding methods for building and displaying markup on the client side. Though I haven’t posted any examples here before, rendering markup on the client is a technique that I use often and recommend.

By sending only data to the client, you can profoundly reduce the size of what you send and see a substantial increase in performance. You also allow yourself the ability to easily add features like light-weight sorting and paging on the client. This can not only improve your users’ experience, but reduce server load and bandwidth requirements.

To that end, I’m going to walk you through these four steps to effectively implementing a client side Repeater, using ASP.NET AJAX and jQuery:

  • Create an RSS Reader page method to return JSON data to the client.
  • Call that page method with jQuery.
  • Use the returned data to build a table on the client side.
  • Improve upon the table creation with a templating plugin.

Click here to read the rest of this post »

3 mistakes to avoid when using jQuery with ASP.NET AJAX

AJAX, ASP.NET, JavaScript, jQuery By Dave Ward on June 5th, 2008

Over the past few weeks, I think I have definitely embodied Jeff Atwood’s claim that we’re all amateurs, learning together. Despite my best efforts to thoroughly test before posting, a few problems slipped through in my recent posts about using jQuery to consume ASP.NET JSON serialized web services and using jQuery to call ASP.NET AJAX page methods.

On the bright side, your great feedback in both posts’ comments has reinforced the fact that some of the best content on my blog is the part that you write.

In this post, I’m going to detail three of the problems that were discovered as a result of those previous two posts:

  • An extra requirement when making a read-only request to IIS6+.
  • An oddity in Internet Explorer 7’s XmlHttpRequest class.
  • A common mistake when passing JSON parameters through jQuery.

Finally, I’ll suggest what I now believe to be a best practice usage, taking all of these issues into account.

Click here to read the rest of this post »

Using jQuery to directly call ASP.NET AJAX page methods

AJAX, ASP.NET, JavaScript, jQuery By Dave Ward on May 29th, 2008

When it comes to lightweight client-side communication, I’ve noticed that many of you prefer ASP.NET AJAX’s page methods to full ASMX web services. In fact, page methods came up in the very first comment on my article about using jQuery to consume ASMX web services.

Given their popularity, I’d like to give them their due attention. As a result of Justin’s question in those comments, I discovered that you can call page methods via jQuery. In fact, it turns out that you can even do it without involving the ScriptManager at all.

In this post, I will clarify exactly what is and isn’t necessary in order to use page methods. Then, I’ll show you how to use jQuery to call a page method without using the ScriptManager.

Click here to read the rest of this post »

Using jQuery to Consume ASP.NET JSON Web Services

AJAX, ASP.NET, JavaScript, UI, jQuery By Dave Ward on March 27th, 2008

Animated example of the RSS feed block from this article. In response to many of the articles here, I receive feedback asking how to achieve the same results without using ASP.NET AJAX. As much as I’m a fan of ASP.NET AJAX, I must agree that its JavaScript payload can certainly be a drawback in some situations.

My recent deferred content loading post is an excellent example of that. I was using jQuery for presentational effects, and using a ScriptManager to call a web service. Loading the JavaScript for both frameworks was a bit counterproductive, since the whole point was to improve initial load time.

In this post, I intend to correct that.

First, I’ll cover the two requirements necessary when calling an ASMX web service that’s being JSON serialized by the ASP.NET AJAX extensions. Then, I’ll show you how to do this with jQuery. Finally, I’ll update the deferred content loading example accordingly.

Click here to read the rest of this post »

Why my ASP.NET AJAX forms are never submitted twice

AJAX, ASP.NET, JavaScript, UI By Dave Ward on March 4th, 2008

Animated example of the button disabling technique in this article.The overzealous double-clickers amongst our users often make it desirable to temporarily disable the controls that trigger server side processing. Previously, I’ve shown you how to disable a button during a postback, how to disable a button during a partial postback, and even written a server control to automate the latter.

However, what if you wanted to be more thorough and disable all of the buttons on a page?

In this post, I’m going to show you how to do just that. I’ll also show you how to disable only the buttons in the UpdatePanel raising the event. Finally, for the jQuery users out there, I’ll show you how to simplify the process down to one line of code.

Click here to read the rest of this post »

Boost ASP.NET performance with deferred content loading

AJAX, ASP.NET, JavaScript, Performance, UI By Dave Ward on February 5th, 2008

FireBug graph of net requests
When rolled into the page life cycle of an ASP.NET WebForm, that red bar is one of your application’s greatest enemies. No matter how well you optimize the rest of the page, even one slow task can become the sole factor determining a user’s perception of the entire page’s performance.

In this post, I’m going to show you one way to circumvent that problem. By placing ancillary content in user controls and delaying their load until the core page content has been displayed, you can drastically improve perceived performance.

When broken down into digestible chunks, the technique is easy to implement and lends your application a level of polish that your users are sure to appreciate. The four steps required to accomplish this will be: building the user control, statelessly rendering the control as HTML, providing progress indication, and using ASP.NET AJAX to request and inject that HTML.

Click here to read the rest of this post »

4 ASP.NET AJAX JavaScript UI methods you should learn

AJAX, ASP.NET, CSS, JavaScript, UI By Dave Ward on January 9th, 2008

Wrapping up my series on some of ASP.NET AJAX’s less utilized client side functionality, this post will take a closer look at some of ASP.NET AJAX’s JavaScript UI helper functions. These methods are great because they abstract away most of the tedious work that comes with supporting cross browser compatibility, leaving us with a nice, consistent API.

Specifically, I’m going to show you examples of using addCssClass, getBounds, getLocation, and setLocation to accomplish a few client side UI tasks.

Click here to read the rest of this post »

Best of 2007: 5 most popular posts (and contest winners)

AJAX, ASP.NET, JavaScript By Dave Ward on December 21st, 2007

As of today, the site is exactly one year old. What a year it has been!

I would like to sincerely thank every one of you for making this past year such a blast. Without all of your great comments, emails, links, and kicks, I doubt that I would have been motivated enough to keep putting in all the work that it takes to run this site.

I would also like to especially thank Joe Stagner, Scott Guthrie, and the DotNetKicks community for their considerable support this year.

Click here to read the rest of this post »

Three copies of ASP.NET AJAX in Action still available

AJAX, ASP.NET, JavaScript By Dave Ward on December 20th, 2007

If you haven’t seen the original post with details on the contest, read that first.

If you have, then you know that we’re down to the last day of the contest. So, make sure that you’ve maximized your chances of winning by commenting on the original post and subscribing to my email list.

As promised, if you’re viewing this post in an RSS reader, it will contain instructions on the third way to win your own copy of ASP.NET AJAX in Action. If you haven’t subscribed to the Encosia RSS feed yet, it’s not too late. Even if you subscribe now, you’ll still see the instructions in the footer of this post’s feed entry.

Best of luck to everyone!

Three copies of ASP.NET AJAX in Action up for grabs

AJAX, ASP.NET, JavaScript By Dave Ward on December 17th, 2007

Thanks to Alessandro Gallo and Manning Publications, I am happy to announce that I’m going to be giving away three copies of ASP.NET AJAX in Action this week in celebration of my blog’s one year anniversary.

If you haven’t read ASP.NET AJAX in Action, you really owe it to yourself to check it out. The book does a great job of helping you understand what’s actually going on under the hood, not just the syntax of the controls. That sort of intimate understanding of the fundamentals is crucial when creating real-world AJAX solutions.

The book goes on to explain all of the ASP.NET AJAX server controls and show full examples of their use, while continuing to keep you aware of any consequences that a particular strategy might have. It also delves into more advanced topics a bit, like building AJAX enabled controls, the ASP.NET AJAX futures, and how to maintain unique URLs for intermediate points in your AJAX application’s workflow.

I don’t generally read technical books about practical application, but I couldn’t put this one down. If you’re reading my site, there’s an awfully good chance that you’d enjoy this book.

Now, on to the fun stuff. I’m going to select winners for the books in three different ways:

Click here to read the rest of this post »