AJAX problems for newbies

Tags: .NET, AJAX, Ajax.NET, ASP.NET, IE

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

  1. 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 visibility style to hidden on the client. If you want to have the same value for the visibility value on the server you have to post it back, with AJAX or a full postback.
  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.
  3. 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.
  4. 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.

2 Comments

  • Manuel said

    I have two weeks trying to get started with ajax but my projects dont work following ur examples.

    I put the ajax.dll on the project folder
    and do exactly as u do in ur vide (changin ajax.javascriptmethod for ajax.ajaxmethod)

    in the part where u put code in the web.config and then it is supose to automaticaly put some code in the html id toesnt do it for me.

    and i dont know where the common.ashx file is but i still wirte it manually anyways
    it doesnt work.
    the page does nothing

Comments have been disabled for this content.