Rob Farley

Rob Rob Farley has been consulting in IT since completing a Computer Science degree with first class honours in 1997. Before moving to Adelaide, he worked in consultancies in Melbourne and London. He runs the development department in one of Australia's leading IT firms, as well as doing database application consultancy and training. He heads up the Adelaide SQL Server User Group, and holds several Microsoft certifications.

Rob has been involved with Microsoft technologies for most of his career, but has also done significant work with Oracle and Unix systems. His preferred database is SQL Server and his preferred language is C#. Recently he has been involved with Microsoft Learning in the US, creating and reviewing new content for the next generation of Microsoft exams.

Over the years, Rob's clients have included BP Oil, OneLink Transit, Accenture, Avanade, Australian Electorial Commission, the Chartered Institute of Personnel and Development, the Royal Borough of Kingston, Help The Aged, Unisys, Department of Treasury and Finance (Vic), National Mutual, the Bible Society and others.

Did you mean to come here? My blog is now at http://msmvps.com/blogs/robfarley



29 November 2005

Ajax experiences

I promised I'd write something about my AJAX experiences, so here goes:

I'm using AjaxPro, by Michael Schwarz. I'm using it so that people can quickly fill out a form without having to post back the whole page all the time. As you pick the details, it updates later parts of the form so that you're only prompted for the correct parts, and you don't have to keep posting back and reloading menus and stuff like that.

I have a textbox which has an event on it that calls an Ajax method, to populate a drop-down list. It's not a combo box, it's a list. That way, the user gets to see the whole list, not just a single entry. I could've returned a dataset from Ajax, but it was a heap easier to create the list in C# and then return the rendered HTML, which I apply to the InnerHTML property of a div tag.

I use the same rendering concept to display whole chunks of forms. It does mean that I need to handle the elements from Request.Form, because I'm dynamically generating the form elements, but I'm fine with that. It's only a form submission - it's not like I'm trying to handle various events.

The biggest problem I came across was form validation. I had some C# code which created a JavaScript function for validation. But it wouldn't get called by the browser. I took the validation code out of the function and put it directly into the form element event, and it worked just fine. I figure that the browser does something funky to know what functions are available, such that it doesn't like to introduce new functions after the page has loaded. Or something like that. I'm happy to wrong on this point - but I got it working nicely.

I like Ajax as a technology. The page works great under both Firefox and IE, and it seems really responsive. You can annoy it by changing the selected items really quickly, but to get around that I used a timer, so that it only puts the request in 0.1s after the user clicks. That way, a second click that's too quick doesn't stress it out too much. The problem seems to be with the client making too many requests, not the server handling it.