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, Reading 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 »

Work smarter: MS AJAX’s JavaScript type extensions

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

In my last post, I began a series exploring ASP.NET AJAX’s client side functionality. If you missed it, you can catch up by reading that post about the various uses of $addHandler.

In this post, I want to take a look at a few more under-appreciated tools that we’re provided with as a part of the framework: Base type extension methods.

Specifically, I’m going to provide some examples of using Array.contains, Date.format, and String.format.

Click here to read the rest of this post »

Using pageLoad in both Master and Content pages

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

Reader Kevin posed a good question in response to my last post, the answer to which is useful enough to warrant a separate post:

I have a situation where I call a page load handler from a script associated with a master page, then on a specific page based on that master page I need to call a second page load handler. I use the pageLoad() shortcut notation in the master page script. I can’t get either pageLoad() (expected since the composite page would have two pageLoad’s) or $addHandler(document, “load�, mySpecificPageLoad()) to work. I had to resort to my old “addLoadListener� function to add the second page load event handler. Is this as expected?

As he mentions, there’s only room in the page’s DOM for one pageLoad shortcut function, preventing both a master and content page from utilizing the shortcut simultaneously.

To work around this limitation, simply add this to your master’s pageLoad:

<script type="text/javascript">
  function pageLoad() {
    // Master pageLoad() code.
 
    // If function contentPageLoad exists, execute it.
    if(typeof contentPageLoad == 'function')
      contentPageLoad();
}

Now, contentPageLoad is executed on any content page you wish to include it on, just as if it were pageLoad. If you don’t include it on a particular content page, the conditional will prevent its execution (and subsequent JavaScript error).

You could use Sys.Application.add_Load to wire up a custom pageLoad on every single content page, but I think the DRY-ness of this approach is preferable. The above method also allows you to retain control of the order of execution, through the placement of the contentPageLoad call in pageLoad.

Exploring one of MS AJAX’s often overlooked features.

AJAX, ASP.NET, JavaScript By Dave Ward on November 15th, 2007

It’s easy to think of the ASP.NET AJAX framework primarily in terms of the server controls it provides. However, make sure that you don’t overlook the client script helper classes at your disposal. Many of them are very useful and surprisingly powerful.

In the next several posts, I’ll be examining these client side helper classes and hopefully giving you some ideas for more effectively using them.

In this first post, I’m going to take a closer look at $addHandler.

Click here to read the rest of this post »

Inline Edit Box .NET (v0.7)

AJAX, ASP.NET, JavaScript, UI By Dave Ward on October 30th, 2007

Mike’s been extremely busy this month, but found time to update Inline Edit Box .NET for us. Changes since version 0.5 include:

  • Added option for single click or double click (new Public Property called ClickMode: enum [SingleClick|DoubleClick])
  • Added “ClientIDSuffixâ€? property to allow for repeater/web control objects.
  • Added “Modeâ€? property. Allows to specify “Adminâ€? or “Displayâ€? modes.
  • Fixed PostBack issues with regards to control properties.

Head over to the Inline Edit Box .NET page for the download link and more information.

Easy incremental status updates for long requests

AJAX, ASP.NET, JavaScript, UI By Dave Ward on October 3rd, 2007

Animation of the multi state progressA problem that has always plagued web developers has been providing detailed progress indication for server-side tasks. The stateless nature of the HTTP protocol makes implementing a mechanism for constant, stateful progress information cumbersome. The main problem is that a given group of server side tasks will generally only result in one, aggregate response from the server.

In the ASP.NET community, several solutions have been offered. Some even provide an entire framework for monitoring the status of tasks in progress. However, they are convoluted and depend on constant server polling. I find polling for progress indication to be an inefficient approximation, when exact data is readily available.

With that in mind, I’d like to share an alternate method that I’ve used in the past with great success.

Click here to read the rest of this post »

ASP.NET AJAX Timer Trouble? Location is key.

AJAX, ASP.NET, JavaScript, Performance By Dave Ward on September 19th, 2007

If you’ve made much use of the ASP.NET AJAX Timer control, you may have noticed that it can behave somewhat unexpectedly. In this post, I’m going to take a closer look at how the Timer works and the most significant factor that influences it: Location.

Where the timer is placed on the page actually varies how it operates. As a Timer’s delay interval approaches the processing time of its resulting PostBack, the difference that the Timer’s location makes becomes very significant.

Click here to read the rest of this post »