Ajax Partial Rendering

When programming a web application you should consider partial rendering as the middle ground to fully fledged Ajax apps. My personal opinion is that Ajax makes life a lot easier for the user and here
I am going to show you how to add Ajax partial page rendering.

ScriptManager
The script manager manages all client side scripts that Ajax uses. By adding the script manager control to your web page you are adding the scripts that are needed to support Ajax.
These scripts are used to support partial rendering and the script manager takes care of the partial rendering cycle for you using these scripts.


Note:
You can only have one script manager to a page if you wish to add script to the same script manger use the ScriptManagerProxy.

UpdatePanel
Update panel is a section that gets updated when any of its controls cause a post back. You can have multiple update panels.

Partial Rendering
Partial rendering is when an event is fired from an update panel registered control. The script manager will take over from the post back life cycle at a
certain stage and use the xmlhttpRequest object to execute and retrieve data from the server side and display that data in the update panel area by using DOM or DHTML.
So the entire page is not being posted back and the user just experiences an asynchronous update.

XMLHttpRequest example

var request = new XMLHttpRequest();
request.open("GET", url, false);
request.send(null);
if (!request.getResponseHeader("Date")) {
    var cached = request;
    request = new XMLHttpRequest();
    var ifModifiedSince = cached.getResponseHeader("Last-Modified");
    ifModifiedSince = (ifModifiedSince) ?
      ifModifiedSince : new Date(0); // January 1, 1970
    request.open("GET", url, false);
    request.setRequestHeader("If-Modified-Since", ifModifiedSince);
    request.send("");
    if (request.status == 304) {
        request = cached;
    }
}


Partial Rendering Example
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
   
</ContentTemplate>
</asp:UpdatePanel>

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



 

Dilbert of the day