AJAX problems for newbies

Michael Schwarz on Wednesday, November 9, 2005

I have some items I learned about AJAX (or Ajax.NET Professional [1]) developer newbies:

<li><font size="2">You cannot access the controls or HTML elements on your web site if you are using DOM/DHTML on the client-side to modify data. Without a postback you will not get the changed parts of the page. An example: if you have a placeholder control you can set the <em>visibility</em> style to <em>hidden</em> on the client. If you want to have the same value for the <em>visibility</em> value on the server you have to post it back, with AJAX or a full postback.</font></li> <li><font size="2">You should not do too many AJAX requests. One reason is that you can only have two connections at the same time (with one process, i.e. with one running iexplore.exe). If you want to initialize a lot of controls on window onload event you should pack it in one method. If you have some initializing data use the JSON serializer to write this data as a JavaScript to the page instead of invoking a AJAX request later.</font></li> <li><font size="2">The Session and Cache collections are available through the System.Web.HttpContext.Current static value. You can also implement the preferred way with implementing the IContextInitializer interface. This will be needed for future developments.</font></li> <li><font size="2">AJAX should not be used to get MBs of data back to the client. Also, you should have a look at the viewstate, some developers showed me pages that are filling DataSets from a database during Page_Load and again, if they are using AJAX. Decide what you want to use and load within AJAX or the common ASP.NET Page.</font></li>