Friday, May 27, 2005


Ajax.NET is a really nice, easy to use library that should be able to help anyone get up to speed quickly with cross-browser compatible AJAX.

If you don't know what AJAX is, visit the link, there's a few nifty examples. The nice thing about Ajax.NET is that it supports Types not inheriting from Page. This is a big advantage since it means you can basically keep a very clean Controller design, and just plugin AJAX capable controls in place of traditional ones.

The hardest thing about a recent AJAX feature I toyed with for an application (an auto-complete TextBox, and yes I know there's free examples out there, I wanted the practice) was not using the library. I literally had that done in 15 minutes and that includes reading the docs. The hardest part was that I wanted the drop-down to be an iframe so I wouldn't have to worry about SelectBoxes with infinite z-index in IE. To do this took a lot of work. In the past I've used hidden iframes for communication, but the elements I was using to pass values were actually in the page already. I never had to generate/add elements (in an iframe) on the fly before. Add to that I couldn't use InnerText (FireFox doesn't support it), appendChild() (IE doesn't support it within an iframe), and IE & FF access iframe content differently and it was a tough nut to crack.

Still, in the end, the results came out very nicely, so it was worth it I suppose. Of course there are Controls you can buy that will do this for you. I think the bigger draw to AJAX is things like validation, authentication, postback-less editing, etc.

I messed with authentication a few minutes before work today, but it seems you can't call FormsAuthentication.Redirect... within an Ajax.NET method. Not sure why. Could possible be because there is no postback?

Edit: Got interrupted there. Ok, so anyways, my thoughts were a Redirect isn't really a force-update of the client's URL. It's a substitution in the HttpStream that the client is already recieving. So you can't Redirect from an AJAX call.

So what can I do? Well, I can just change the location with Javascript. As long as I have a valid FormsAuthentication ticket, then the new location target won't get bounced.

The down-side is this doesn't degrade gracefully. Ok... should I care? I mean really, ASP.Net depends on postbacks pretty heavily. Anything "cool" is going to require some Javascript support. Is there any need to support browsers that don't support Javascript? Is it an accessability issue? I think some things can be, like the auto-completion TextBox. A login though? I'm just substituting Microsoft's doPostBack() with my own logic. I don't see that as a problem. What do you think though?
Comments: Post a Comment

<< Home

This page is powered by Blogger. Isn't yours?