# Thursday, November 09, 2006

I attended another whiteboard discussion on the subject but elected not to post anything about it because it really was a waste of time. I chose to try my luck one more time as the moderator of the session would be Nikhil Kothari. Unfortunately it turned out that he has fallen sick and so we had a couple of other guys from the team take his place. Now this wasn't a bad thing by any means. Their names elude me right now but we had a Product Manager for AJAX and the developer who did UpdatePanel which if you've done anything with ASP.NET AJAX will know about. Both were very knowledgeable on the subject and we had a great discussion. We were kind of all of the map with a lot of focus on both ASP.NET 2.0 in general and of course ASP.NET AJAX.

They set the record straight about the composition of the AJAX package something I've already done a post about. Other than the general discussion I took away three things:

ControlState is a new construct of ASP.NET 2.0 which I'd forgotten everything about. If you are a control developer you need to keep this one in mind. We all know that ViewState can be rather bloated so we turn if off in places we don't need. Now I don't know about you but I've done my fair share of controls which will explode if someone turns off ViewState on them, simply because that's the only option we had in the past for saving temporary data. With ControlState however the story is different. You simply cannot turn off ControlState. This means two thing for us: 1) We can happily go on creating our state bound controls, 2) We should take care to only store what is absolutely critical for the control to work in ControlState. Think about the DataGrid, what if someone decided to place its state data exclusively in ControlState. Not a pretty picture I'm sure.

== is not ==

What do I mean with that? Well it turns out that Javascript has a very funky implementation of our dear == and != operators. What it does is that it tries to do some magic for some reason to create maybe a better comparison? Whatever the case the end result is that you get some very weird results when using == and != in Javascript. The rule of thumb is to use === (yes triple equals) and !== because to behaving more like what we are used to in C#. That's certainly something to keep in mind.

Finally Nikhil has some very cool tools. Where I'd like to point your attention in the direction of his tools page and Script# in particular. Script# is a tool written in frustration with Javascript. Nikhil wanted a way to write Javascript without writing Javascript, the solution? Create a tool you write C# code in and then let it convert it to Javascript. For a person like me who's done very little clientside development and certainly never any systems with an actual Javascript strategy it looks like a great tool. I certainly will be doing some experimentation in the very near future.

Someone asked a question about who you deal with multiple concurrent HTTP connections from an AJAX frontend. Browsers today pretty much limit you to two connections per domain as a default. So what what do you do if you need more than that? A trick suggested is to create multiple subdomains and have your website respond to requests on additional host headers to trick the browser into believing that the request goes to different servers. A technique used by local.live.com for example.

Regarding performance there's one caveat that you should know about when dealing with AJAX and even ASP.NET: Never deploy a site with debug set to true. It's always been true for ASP.NET now even more so. The reason is that AJAX comes with two sets of scripts: One for debug mode and a more efficient one for release mode. They are equivalent in functionality but the debug script include lots more code and as you can imagine it's in hum readable form. What AJAX will do to optimize performance in release mode is to replace variable names with shorthand names in order to speed up parsing of our scripts. It will also remove some type checking in the library which under debug mode checks whether the correct types are passed to the AJAX Library functions. Finally whitespaces will be removed to keep the script lightweight and again to speed of parsing.

Comments are closed.