Thursday, March 8, 2007

ASP.Net Ajax as a Tool

Libraries are abstractions that make it easier to do things that can already be done. Sure, you could write your own code that parses XML files, but it's a lot easier, quicker and more reliable if you use one that someone else wrote. If that library doesn't work correctly or doesn't make the job easier, it's not usable. Flexibility is a bonus. It's useful if you can use the same library for image resizing and image format conversion but if there isn't one, you can just use two libraries. If a library is too inflexible, it becomes usable. A library that takes any image and resizes it to 32 x 32 isn't useful at all if I want 48 x 48.

ASP.Net Ajax is an odd case. It makes some thing extremely easy, and for that alone it's going to get wide usage. UpdatePanels are an extremely easy way to avoid whole page refreshes for minor changes and lower bandwidth usage. The Control Toolkit has a little bit of a learning curve but it's also a great tool to do some useful things on web pages.

It's almost a shame that the javascript libraries are a mess. They are extremely intimidating, and my attempts to dig into it have been discouraging. Javascript is a very lean and powerful language and I have to wonder if there's a benefit of a namespace and class system is necessary. The UpdatePanel and Control Toolkit is built on top of the javascript libraries, so I'm going to have them at my disposal and I may as well use them.

I want to use them. There are problems I'd like to solve that require Javascript and I don't want to bloat my site with more than one library. Specifically, I'd like to go to the server, do some processing, and send back code that modifies one element on the page, similar to Unobtrusive Javascript in Rails. The UpdatePanel is overkill, it will update the entire section. I don't think ASP.Net Ajax can do this explicitly and I would like to write and share an Unobtrusive Javascript control for that library, but I don't know if I will. It seems like it will be much easier to avoid using the javascript library and create a separate library that I would probably not share.

No comments: