The ability to integrate partial page rendering is integrated into ASP.NET with small changes to your project. Let’s start by integrating partial rendering into an existing project. Assuming that you have Visual Studio 2008 you can start.

To begin, start Visual Studio 2008, and create a new page by clicking File > New > Web Site > ASP.NET and name it AjaxPPRender or whatever you would like. Now you are in front of a blank default.aspx page with basic markup. First, drag and drop a Label control (lblLabel), and a Button control (btnButton) onto the page with the form element.

Set the Label text properties to “Congradulations! You have clicked the Button!” and the Button text to “Click”. Now navigate to the code behind view or double click the btnButton to generate the button handler. Then set the lblLabel.Text to “Congradulations! You have clicked the Button!”. The default.aspx markup should look similar to example below:

he default.aspx.cs page should look similar to this example below:

**Important: Either way drag or type in the closing tag past the end of the button element so that the lblLabel and btnButton controls are wrapped. Then after that tag, open a new tag called .. This tag should wrap around the lblLabel and btnButton tag as well.

Anywhere within the element inlcude a ScriptManager control by simply double clicking it in the toolbox. After you place that tag in change include the attribute EnablePartialRendering=”true”.


Notice if you open your web.config file you should notcie that Visual Studio has automatically added a complilation reference to System.Web.Extensions.dll. Now if you run your Web site you can notice how no source code changes were required to support partial page rendering; only the markup was changed.

Notes:

The ScriptManager control is a very important control within the ASP.NET AJAX Extensions. It provides access to the script library, supports partial rendering, and provides extensive support for additional ASP.NET services. Some of those services include authentication and profiling. It also provides globalization and localization support for the client scripts.

Learn How to Handle Custom Errors for UpdatePanels

We will quickly go over how to handle custom errors for UpdatePanels. Despite that updates are handled by triggers determined by UpdatePanel controls, the support for error and custom error handling messages is by a page’s ScriptManager control instance. By exposing an event, AsyncPostBackError, to the page can appropriately provide custom exception handling logic.

When applying a AsyncPostBackError event, specify the AsyncPostBackErrorMessage property, which will then prompt an alert box to be raised upon completion of the callback. Also, client side customization is also possible instead of the default alert box. For example, if you want to display a customized element rather than box. In a case like that you might handle the error like this example below:

The code script above registers a callback with the client side AJAX runtime after the asynchronous request has been complete. Then it checks for an error, if so, processes, then indicates to the runtime that the error was handled in a custom script.