Common PostbackManager


Purpose
This sample illustrates the implementation and use of a PostbackManager, which is a utility control that provides a simple way to issue asynchronous requests and manipulate requests made by Web Application Developer Framework (ADF) controls. Asynchronous requests can be made via the PostbackManager doAsyncRequest method and processed in the Web tier via the RequestReceived event. Requests made by Web ADF controls can be manipulated before they are sent to the server via the PostbackManager client tier invokingRequest event. As with requests issued by calling doAsyncRequest, these can also be handled in the Web tier RequestReceived event. Responses to Web ADF control requests can be processed via the client tier requestProcessed event.
 
This functionality can be made available by adding a PostbackManager to the page. The exposed members function the same regardless of whether callbacks or partial postbacks are used for asynchronous behavior.
 
This sample provides the following examples:
  • ProgressBarOnRequest.aspx—Illustrates use of the PostbackManager client tier invokingRequest and requestProcessed events to show a progress bar when a Web ADF request has been issued.
  • CreateGraphicElement.aspx—Illustrates use of the PostbackManager doAsyncRequest and RequestReceived events to send geometry drawn in the client tier to the Web tier.
  • GetAttributeTable.aspx—Demonstrates how the PostbackManager invokingRequest, RequestReceived, and requestProcessed events can be used to display a table containing a layer's attributes when that layer is clicked in the table of contents (TOC). The doAsyncRequest method is used to enable sorting and paging for the attribute table.

How to use

Data has been provided for your use with this sample. It can be found at <Your ArcGIS Developer Kit Install directory>/Samples/data/Usa/USA.mxd.
If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

At design time
  1. Verify that the Web ADF for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
  2. In Windows Explorer, navigate to <ArcGIS Developer Kit install location>\Samples\ServerNET\Common_PostbackManager.
  3. Open the folder of the language you're going to use—CSharp or VBNet—and copy the Common_PostbackManager_<language> folder to c:\inetpub\wwwroot. The <language> variable can be either CSharp or VBNet.
  4. Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services.
  5. In the console tree view on the left, navigate to Local Computer > Web Sites > Default Web Site, expand Default Web Site and the Common_PartialPostback_<language> folder, right-click the PostbackManagerWebSite folder, and click Properties. The Properties dialog box opens.
  6. Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
  7. Start Microsoft Visual Studio 2008 or 2010, and open the solution for the version of Visual Studio you're using. The Visual Studio version is appended to the solution file name. For example, the Visual Studio 2008 solution file for the Common_PostbackManager_CSharp sample is Common_PostbackManager_CSharp2008.sln and is located in the c:\inetpub\wwwroot\Common_PostbackManager_CSharp folder.
  8. In Solution Explorer, right-click the page you want to view and select Set As Start Page.
  9. The pages in this sample are configured to use the USA map service, and it is assumed that this is running on your local machine (localhost). You can create this service by publishing the map document located at <ArcGIS Developer Kit install location>\Samples\data\Usa\USA.mxd. For instructions on how to publish a map document to ArcGIS Server, see the Publishing a GIS resource to the server topic in the ArcGIS Server Help.
  10. If this service is not running on the local machine, you must specify the proper location. To do this, open the page you want to view in Design view, click the MapResourceManager control, and click the ellipsis next to the ResourceItems property in the properties window. The ResourceItem Collection Editor dialog box opens.
  11. Click the ellipsis next to the Definition property. The MapResource Definition Editor dialog box opens.
  12. In the Data Source field, replace localhost with the name of the machine hosting the service.
  13. Save the project.
  14. Click the Debug drop-down menu and click Start Debugging.

Run ProgressBarOnRequest.aspx
  1. Use the controls on the page to zoom the map, execute the Query Counties task, toggle layers in the TOC, and so on. A progress bar often appears in the lower right corner of the map. The progress bar is shown when a Web ADF control issues a request via the PostbackManager invokingRequest event and is hidden when a response is received via the requestProcessed event.

Run CreateGraphicElement.aspx
  1. Press and hold the A key and click several points on the map. Point features with varying sizes and symbology appear at the clicked points. The geometries for these points are sent to the server through the PostbackManager doAsyncRequest method. Then, in a handler for the Web tier RequestReceived event, these points are used to create GraphicElements, which are added to a GraphicsLayer and displayed on the map. With the Line or Polygon check box checked, feature geometries of the corresponding type are similarly captured on the client and processed on the server.

Run GetAttributeTable.aspx
  1. Check the Get Layer Attribute Data check box.
  2. Expand the MapResourceItem node on the TOC.
  3. In the TOC, click the States Layer. A progress indicator is displayed above the TOC, followed by a FloatingPanel containing a table showing the attributes of features in the States layer. A handler for the PostbackManager invokingRequest event is used to intercept and add an argument to the request generated by the TOC when a layer is clicked. In the Web tier, a handler for the RequestReceived event checks for this argument and, when found, queries the clicked layer and generates the attribute table. Once a response is received on the client, a handler for the requestProcessed event applies a title to the FloatingPanel containing the attribute table.
  4. Click the paging buttons. The first, last, subsequent, and previous pages of attributes can be quickly retrieved.
  5. Click a column heading. The table is sorted on the clicked column. These functions all use the PostbackManager doAsyncRequest method to issue an asynchronous request, which is then processed in the Web tier by a handler for the PostbackManager RequestReceived event.

Common_PostbackManager_CSharp\PostbackManagerWebSite\ProgressBarOnRequest.aspx Displays a progress bar when a Web ADF control issues a request.
Common_PostbackManager_CSharp\PostbackManagerWebSite\CreateGraphicElement.aspx Captures geometries drawn on the client and sends them to the server.
Common_PostbackManager_CSharp\PostbackManagerWebSite\CreateGraphicElement.aspx.cs Code behind the user interface.
Common_PostbackManager_CSharp\PostbackManagerWebSite\GetAttributeTable.aspx Displays an attribute table when a layer is clicked in the TOC.
Common_PostbackManager_CSharp\PostbackManagerWebSite\GetAttributeTable.aspx.cs Code behind the user interface.
Common_PostbackManager_CSharp\PostbackManager_CSharp\PostbackManager.cs Implementation of the PostbackManager control's Web-tier functionality.
Common_PostbackManager_CSharp\PostbackManager_CSharp\JavaScript\PostbackManager.js Implementation of the PostbackManager control's client-tier functionality.
Download the C# files
Common_PostbackManager_VBNet\PostbackManagerWebSite\ProgressBarOnRequest.aspx Displays a progress bar when a Web ADF control issues a request.
Common_PostbackManager_VBNet\PostbackManagerWebSite\CreateGraphicElement.aspx Captures geometries drawn on the client and sends them to the server.
Common_PostbackManager_VBNet\PostbackManagerWebSite\CreateGraphicElement.aspx.vb Code behind the user interface.
Common_PostbackManager_VBNet\PostbackManagerWebSite\GetAttributeTable.aspx Displays an attribute table when a layer is clicked in the TOC.
Common_PostbackManager_VBNet\PostbackManagerWebSite\GetAttributeTable.aspx.vb Code behind the user interface.
Common_PostbackManager_VBNet\PostbackManager_VBNet\PostbackManager.vb Implementation of the PostbackManager control's Web-tier functionality.
Common_PostbackManager_VBNet\PostbackManager_VBNet\JavaScript\PostbackManager.js Implementation of the PostbackManager control's client-tier functionality.
Download the VB.NET files

Download the files for all languages