AJAX Enabled Pages

For the most part, I’ve found it pretty easy to ‘AJAX’ify a web page, but there are a few quirks and gotchas. I’ll try to list a few of the ones I’ve stumbled across here.

1083329_34219330small

File Uploads
The file upload controls (FileUpload and HTMLInputFile) are not AJAX compatible. In order to use them inside an updatePanel, you must set the actual submit button that uploads the file, to be a postbackTrigger in the triggers section of the updatePanel. Setting it as an asyncPostbackTrigger will not work.

In addition, if the upload control is not visible when the page is first loaded, the uploads will not work. So, if you have the upload control on a panel that is .visible=false, it’s not going to work. If you really need to have the panel invisible, you’ll need to do it with a style setting (display: none) and change the style to make it visible. This relates to the fact that things that have visible set to false aren’t really invisible, so much as they are just not there at all. So, go with hidden instead.

When converting older ASP 1.1 era pages to AJAX, make sure you update the doc type. The following should work (or you can use newer ones like the XHTML ones):

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

The XHTML can change the rendering quite a bit, so you have to be careful when you play around with this. (Doctype issues are big enough for another whole topic, so I won’t go into details here.)

If you’re playing with AJAX, you’ll want to look at the AJAX control toolkit and probably jQuery as well. These tools make it easy to add usability enhancements to your web pages.

  • Share/Bookmark

About the Author

David is an IT professional with over 26 years of experience (he started his career as a teenager). He has programmed in more languages and on more types of computers (and similar devices) than he can remember, including TRS-80 Model I Level 2, Commodore Vic-20 and C-64, C-128, Industrial Process Controllers, CP/M machines, and Intel 80x86+ architectures. He currently uses Microsoft .NET Framework tools and SQL Server. When he's not geeking out, he studies the Martial Art, Aikido; engages in community volunteer work; writes fiction (as well as non-fiction blogs); and does home rennovation work. He lives in Charlotte NC, USA.