Under the hood of the UpdatePanel in .NET

Creator PDF417 in .NET Under the hood of the UpdatePanel

Under the hood of the UpdatePanel
Draw PDF 417 In Visual Studio .NET
Using Barcode printer for ASP.NET Control to generate, create PDF-417 2d barcode image in ASP.NET applications.
www.OnBarcode.com
Barcode Creation In .NET Framework
Using Barcode creator for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Figure 7.4 A client-side event viewer application will let you observe how the PageRequestManager and partial-page rendering mechanism works.
Code 39 Drawer In Visual Studio .NET
Using Barcode encoder for ASP.NET Control to generate, create Code-39 image in ASP.NET applications.
www.OnBarcode.com
Drawing Barcode In Visual Studio .NET
Using Barcode creator for ASP.NET Control to generate, create Barcode image in ASP.NET applications.
www.OnBarcode.com
Getting started
Printing 2D Barcode In Visual Studio .NET
Using Barcode drawer for ASP.NET Control to generate, create Matrix Barcode image in ASP.NET applications.
www.OnBarcode.com
Create GS1 - 13 In VS .NET
Using Barcode drawer for ASP.NET Control to generate, create EAN13 image in ASP.NET applications.
www.OnBarcode.com
The first step is to create a new Ajax-enabled site. Using the Visual Studio template provided by the installation package (see chapter 1 for more details), create the site and add the markup shown in listing 7.3.
Creating UPC-A In .NET
Using Barcode generator for ASP.NET Control to generate, create UPC A image in ASP.NET applications.
www.OnBarcode.com
ISSN - 13 Drawer In Visual Studio .NET
Using Barcode creation for ASP.NET Control to generate, create International Standard Serial Number image in ASP.NET applications.
www.OnBarcode.com
Listing 7.3 The general layout for the client-side event viewer Enable partial rendering
Decode PDF-417 2d Barcode In C#
Using Barcode reader for Visual Studio .NET Control to read, scan read, scan image in .NET framework applications.
www.OnBarcode.com
PDF-417 2d Barcode Generation In C#.NET
Using Barcode drawer for .NET framework Control to generate, create PDF417 image in .NET framework applications.
www.OnBarcode.com
<form id="form1" runat="server">
Print Barcode In Java
Using Barcode encoder for Java Control to generate, create Barcode image in Java applications.
www.OnBarcode.com
Generating Barcode In Java
Using Barcode printer for Android Control to generate, create Barcode image in Android applications.
www.OnBarcode.com
<asp:ScriptManager ID="ScriptManager1" runat="Server" /> <div> <table> Client-side <caption>Client-Side Event Viewer</caption>
Code-128 Decoder In VB.NET
Using Barcode reader for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Drawing EAN / UCC - 13 In Java
Using Barcode creation for Android Control to generate, create EAN / UCC - 13 image in Android applications.
www.OnBarcode.com
events
Encode Data Matrix ECC200 In Java
Using Barcode creator for Java Control to generate, create ECC200 image in Java applications.
www.OnBarcode.com
Barcode Reader In Java
Using Barcode Control SDK for BIRT Control to generate, create, read, scan barcode image in BIRT reports applications.
www.OnBarcode.com
<thead> <tr> <th scope="col">Event</th> <th scope="col">Details</th> </tr> </thead>
Paint 2D In Java
Using Barcode maker for Java Control to generate, create 2D image in Java applications.
www.OnBarcode.com
Scanning ANSI/AIM Code 128 In VS .NET
Using Barcode recognizer for VS .NET Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
A client-side event viewer
UPC A Encoder In .NET
Using Barcode creation for Visual Studio .NET Control to generate, create UCC - 12 image in .NET framework applications.
www.OnBarcode.com
Paint GS1 - 12 In Java
Using Barcode encoder for Java Control to generate, create UPCA image in Java applications.
www.OnBarcode.com
<tfoot> <tr> <td align="left" colspan="2"> <a href="#" onclick="clearEvents();">Clear  <asp:Image ID="Clear" runat="server" ImageUrl="~/images/trashcan.gif" ImageAlign="AbsBottom" AlternateText=""/> </a> </td> </tr> </tfoot>
Footer
<tbody id="clientEvents"> </tbody> </table> </div> </form> <script type="text/javascript">
Body for displaying events
Clear function clearEvents(){ events var events = $get('clientEvents'); while (events.firstChild) { events.removeChild(events.firstChild); } }
</script>
Examining the code, the first thing to notice is the required B ScriptManager control at the top. With its presence and the EnablePartialRendering property set to true (the default value), the page becomes Ajax-enabled and the PageRequestManager object is available. Next is the basic C table structure you use to display the client-side events. Information about each event is populated in the E body of the table and can be cleared from the D footer by clicking the hyperlink that calls the F clearEvents function. Pretty straightforward so far you ve put together the overall UI layout and can now start working with the events.
Handling client-side events
With the basic structure in place, you can begin by adding the first handlers for a few of the events raised by the Application object. Listing 7.4 demonstrates how to add the handlers and the way information about each of them is captured and displayed on the page.
Under the hood of the UpdatePanel
Listing 7.4
Raising the init and load events with the Application object
<script type="text/JavaScript" language="javascript"> <!-// Application events Sys.Application.add_init(onInit); Add event Sys.Application.add_load(onLoad); handlers
function onInit(sender, args){ var row = createEventRow("init", ""); $get('clientEvents').appendChild(row); } function onLoad(sender, args){ var details; if (!args.get_isPartialLoad()){ details = "Normal postback"; } else{ details = "Asynchronous postback"; } var row = createEventRow("load", details); $get('clientEvents').appendChild(row); }
Show init event
Show load event
function createEventRow(eventName, details){ Add row var row = document.createElement("tr"); to table var eventCell = document.createElement("td"); var eventText = document.createTextNode(eventName); eventCell.setAttribute("width", "140px"); eventCell.appendChild(eventText); row.appendChild(eventCell);
var detailsCell = document.createElement("td"); var detailsText = document.createTextNode(details); detailsCell.appendChild(detailsText); row.appendChild(detailsCell); return row; } .... //--> </script>
The events that you re interested in from the Application object are B init and load. The handler for the init event named C onInit updates the event viewer by adding a row to the table body. This is done by calling the local function E
A client-side event viewer
createEventRow. This generic routine adds another row to the body of the table to display information about an event. You ll use this function throughout the section to add information about each event. For the init event, you pass in the name of the event and leave the second parameter, used to display additional details, as an empty string. Next is the load event raised by the Application object and its corresponding D onLoad handler. Here, you check to see if you re currently processing a normal postback or an asynchronous one by examining one of the properties passed in to the event arguments: isPartialLoad. Listing 7.5 reiterates how this is done to format more information about the event.
Listing 7.5 Querying the event arguments to determine whether the postback is asynchronous
var details; if (!args.get_isPartialLoad()){ details = "Normal postback"; } else{ details = "Asynchronous postback"; } var row = createEventRow("load", details);
Update event viewer
The additional information is passed in to the second parameter of the createEventRow function. If you run the application now, you ll see that both events are populated in the event viewer, which shows that you re off to a good start and ready to handle more events. Let s continue by addressing the events raised by the PageRequestManager. Listing 7.6 shows how to add handlers for each of those events as well as some simple code to update the event viewer.
Copyright © OnBarcode.com . All rights reserved.