Common Task results


Purpose
This sample demonstrates how to programmatically create and manipulate Web Application Developer Framework (ADF) task results. Each page in this sample illustrates a different manipulation technique, ranging in difficulty from simple to complex. These techniques enable you to add data to the Map and TaskResults controls with full control over the format and functionality of the data display.
 
The following list gives a brief description of the pages used to manipulate Web ADF task results in this sample, listed in order of complexity:
  • SimpleResult.aspx—Illustrates the creation of a simple task result, containing only heading and detail nodes.
  • DataTableResult.aspx—Demonstrates how to create a task result from a data table.
  • GraphicsLayerResult.aspx—Demonstrates how to create task results from GraphicsLayers.
  • ContextMenu.aspx—Demonstrates how to create and attach a custom context menu to task results.
  • SelectionSet.aspx—Illustrates the creation and update of a single selected set of task results.
  • ZoomToResultsContainer.aspx—Illustrates the use of a custom ZoomToResults TaskResults control to display and automatically zoom to task results.
  • ZoomToResultsFilter.aspx—Demonstrates how to use the custom ZoomToResults to automatically zoom to results while displaying the results in a different TaskResults container.
  • TaskResultsPanel.aspx—Illustrates a custom task that displays task results tabularly in a floating panel.
  • OnDemandResults.aspx—Illustrates a custom TaskResults control that modifies the behavior of task results so that a result's attributes are only retrieved when a feature node or a MapTip is expanded. Includes a QueryAttributesTask that has been extended to implement IAttributesOnDemandProvider, which enables the custom TaskResults control to retrieve a feature's attributes from the control that created the results.

How to use

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 install location>\DeveloperKit10.0\Samples\ServerNET. This folder contains the Common_TaskResults CSharp and VBNet folders.
  3. Open the folder of the language you're going to use—CSharp or VBNet—and copy the Common_TaskResults_<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, right-click the Common_TaskResults_<language> 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, and open the solution for the version of Visual Studio you're using (2008 or 2010). The Visual Studio version is appended to the solution file name. For example, the Visual Studio 2008 solution file for the Common_TaskResults_CSharp sample is Common_MapTips_CSharp2008.sln and is located in the c:\inetpub\wwwroot\Common_TaskResults_CSharp folder.
  8. In Solution Explorer, in TaskResultsWebSite, 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 and California map services, and it is assumed that these are running on the local machine (localhost). You can create these services by publishing the map documents located at <ArcGIS install location>\DeveloperKit10.0\Samples\data\USA\USA.mxd and <ArcGIS install location>\DeveloperKit10.0\Samples\data\California\California.mxd. For instructions on how to publish a map document to ArcGIS Server, refer to the Publishing a GIS resource to the server topic in the ArcGIS Server Help.
  10. If these services are not running on the local machine, specify the proper location by following the steps in the Specify host machine section below.
  11. Save the project.
  12. Click the Debug drop-down menu and click Start Debugging.

Specify host machine
  1. Open the page you want to view, open the properties window for the MapResourceManager control, and click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog box opens.
  2. Click the ellipsis next to the Definition property. The Map Resource Definition Editor dialog box opens.
  3. In the Data Source field, replace localhost with the name of the machine hosting the service.

At run time
  1. Browse to the application uniform resource locator (URL) (for example, http://localhost/Common_TaskResults_CSharp) or start the application from Visual Studio.
  2. Follow the steps for the particular page you're using in the sections below.

SimpleResult.aspx
  1. Click Create Simple Task Result. A simple task result is added to the TaskResults control.

DataTableResult.aspx
  1. Click Execute Query. A task result is added to the TaskResults control.
  2. Expand the task result node and its child nodes. The task result contains nodes with attribute data. These correspond to the rows of a table that was created by executing a query.

GraphicsLayerResult.aspx
  1. Click Select Cities in Current Extent. Task results are added to both the TaskResults and Map controls.
  2. Expand the task result node and its child nodes. The task result contains nodes with attribute data. These correspond to the attributes of the result features shown on the map. The layer definition specified for the Cities layer has been applied to the results.

ContextMenu.aspx
  1. Click Create Task Result with Custom Context Menu. A task result is added to the TaskResults control.
  2. Right-click the Detail node. A custom context menu with a programmatically defined Show Alert item displays.
  3. On the context menu, click Show Alert. The resulting behavior—a JavaScript alert—matches that specified in ContextMenu.aspx.cs.

ShowOnlyOnClick.aspx
  1. Move the mouse pointer over a city feature. No MapTip is displayed.
  2. Click the city feature. The MapTip is now shown.

SelectionSet.aspx
  1. Click the Counties layer on the TOC. The layer is highlighted and, if Internet Explorer is being used, the browser's status bar displays the selection layer.
  2. Click Select Features and draw a rectangle on the map by clicking and dragging. For counties that intersect the rectangle, task results are created and added to both the Map and TaskResults controls.
  3. Click Select Features again and draw a new rectangle on the map. The previous task results are replaced by the features that intersect the new rectangle.

ZoomToResultsContainer.aspx
  1. Click the Find button on the Query Counties task. When the task results are returned, they are automatically zoomed in and displayed in the ZoomToResults control.

ZoomToResultsFilter.aspx
  1. Click the Find button on the Query Counties task. When the task results are returned, they are automatically zoomed in and displayed in the TaskResults control. While this behavior appears identical to that in ZoomToResultsContainer, examining the ZoomToResultsFilter.aspx page reveals the use of both a ZoomToResults control and a TaskResults control. TaskResults is used to display the results, while ZoomToResults simply zooms the map to the results.

TaskResultsPane.aspx
  1. Click the Find button on the Tabular Results Task. The task results' attributes are displayed tabularly in a floating panel.

OnDemandResults.aspx
  1. Click the Find button on the Query Counties task.
  2. Expand the Query Counties and Counties task results nodes, and expand a feature node. An activity indicator is displayed first, then the feature's attributes are displayed.
  3. On the map, hover over the feature corresponding to the node that was expanded. When the feature's MapTip is shown, expand it. The feature's attributes are displayed.
  4. Expand the MapTips for a different result feature. As with the feature node, an activity indicator is displayed first, then the MapTip is updated with the feature's attributes.
  5. Expand the feature node corresponding to the result on which a MapTip was just displayed. The feature node is updated with attribute data along with the MapTip.
  6. Click the Find button on the Search Counties task. The on-demand attributes functionality is enabled for this task's results.

Additional information

For task results created by running tasks in the sample Web site, attributes for a particular result are retrieved upon the following:
  • The result’s MapTip is expanded
  • The result’s FeatureNode is expanded
Retrieving attributes via a MapTip also updates the corresponding FeatureNode and vice versa. Once attributes for a result have been retrieved, they remain on the client, so only one attribute retrieval request is made per result.
 
This functionality is enabled primarily through a custom TaskResults control, called OnDemandTaskResults. This control initializes on-demand functionality for task results that are added to it via a NodeAdded event handler. When the control’s ShowAttributesOnDemand property is true, any spatial results that are added to it have on-demand functionality enabled. This sample only enables on-demand functionality for TaskResultsNodes that contain one or more GraphicsLayerNodes.
 
The results attribute data is either cached in the Web tier by OnDemandTaskResults or retrieved from the control that created the results. By default, attribute data is extracted from the results at the time they are added to OnDemandTaskResults, then stored in the Web tier for later retrieval. In this scenario, only geometry, unique ID, and primary display fields are initially sent to the client for each result. While this reduces the amount of data initially transmitted between the Web application and the client, it does not affect data transmission between the geographic information system (GIS) data server and the Web application; the operating assumption is that all result data is sent to OnDemandTaskResults and is available for Web-tier caching in the NodeAdded event handler. An out-of-the-box SearchAttributesTask is included on the sample Web page to demonstrate this scenario.
 
To achieve on-demand functionality that does not rely on Web-tier data caching, but rather pushes each feature data request all the way to the GIS data server, the control that creates the results must implement IAttributesOnDemandProvider. This is a custom interface included with the sample that includes one method, GetAttributeData. If a set of results is created by a control implementing this interface, OnDemandTaskResults calls the GetAttributeData method when a result’s attribute data is needed, passing the method the unique ID of the feature corresponding to the result. The control implementing IAttributesOnDemandProvider is responsible for retrieving the attribute data and returning it to OnDemandTaskResults. In this scenario, OnDemandTaskResults does not manipulate the result data in any way before it is sent to the client; the assumption is that the results are constructed to include minimal data initially and the appropriate data when GetAttributeData is called. AttributesOnDemandTask, a custom task that extends QueryAttributesTask, is included in the sample to demonstrate how IAttributesOnDemandProvider can be implemented.


Common_TaskResults_CSharp\TaskResultsWebSite\SimpleResult.aspx Illustrates creation of a simple task result.
Common_TaskResults_CSharp\TaskResultsWebSite\SimpleResult.aspx.cs Code behind the .aspx page.
Common_TaskResults_CSharp\TaskResultsWebSite\DataTableResult.aspx Illustrates creation of a task result from a DataTable.
Common_TaskResults_CSharp\TaskResultsWebSite\DataTableResult.aspx.cs Code behind the .aspx page.
Common_TaskResults_CSharp\TaskResultsWebSite\GraphicsLayerResult.aspx Illustrates creation of a task result from a GraphicsLayer.
Common_TaskResults_CSharp\TaskResultsWebSite\GraphicsLayerResult.aspx.cs Code behind the .aspx page.
Common_TaskResults_CSharp\TaskResultsWebSite\ContextMenu.aspx Illustrates the configuration of a custom context menu for task results.
Common_TaskResults_CSharp\TaskResultsWebSite\ContextMenu.aspx.cs Code behind the .aspx page.
Common_TaskResults_CSharp\TaskResultsWebSite\SelectionSet.aspx Illustrates placing task results in a single selected set that is updated when a new selection is made.
Common_TaskResults_CSharp\TaskResultsWebSite\SelectionSet.aspx.cs Code behind the .aspx page.
Common_TaskResults_CSharp\TaskResultsWebSite\App_Code\SelectTool.cs Class containing the implementation of the selection tool.
Common_TaskResults_CSharp\TaskResultsWebSite\ZoomToResultsContainer.aspx Illustrates using a custom TaskResults control to both display and automatically zoom to task results.
Common_TaskResults_CSharp\TaskResultsWebSite\ZoomToResultsContainer.aspx.cs Code behind the .aspx page.
Common_TaskResults_CSharp\ZoomToResults\ZoomToResults.cs Class containing the implementation of a custom TaskResults control that automatically zooms to results.
Common_TaskResults_CSharp\TaskResultsWebSite\ZoomToResultsFilter.aspx Illustrates the use of a custom TaskResults control to automatically zoom to results that are displayed in a separate TaskResults control.
Common_TaskResults_CSharp\TaskResultsWebSite\ZoomToResultsFilter.aspx.cs Code behind the .aspx page.
Common_TaskResults_CSharp\TaskResultsWebSite\TaskResultsPanel.aspx Illustrates a custom task that displays the attributes of results tabularly in a floating panel.
Common_TaskResults_CSharp\TaskResultsWebSite\TaskResultsPanel.aspx.cs Code behind the .aspx page.
Common_TaskResults_CSharp\TaskResultsWebSite\App_Code\TabularResultsTask.cs Class containing a task implementation that displays results in a TaskResultsPanel.
Common_TaskResults_CSharp\TaskResultsWebSite\App_Code\TaskResultsPanel.cs Class containing an extended floating panel implementation for displaying task results tabularly.
Common_TaskResults_CSharp\TaskResultsWebSite\JavaScript\TaskResultsPanel.js JavaScript file containing the client-side implementation of the TaskResultsPanel control.
Common_TaskResults_CSharp\TaskResultsWebSite\OnDemandResults.aspx Illustrates a TaskResults control that has been customized so that attributes for a task result are retrieved only when the result's feature node or MapTip is expanded.
Common_TaskResults_CSharp\TaskResultsWebSite\OnDemandResults.aspx.cs Code behind the .aspx page.
Common_TaskResults_CSharp\OnDemandTaskResults\OnDemandTaskResults.cs Class containing an extended TaskResults implementation that configures task results attributes to be retrieved on demand.
Common_TaskResults_CSharp\OnDemandTaskResults\IAttributesOnDemandProvider.cs Interface specifying the member that must be implemented for an OnDemandTaskResults control to retrieve results from the control that packages the task results. This enables on-demand retrieval of attributes from the GIS data server, rather than from a Web-tier cache.
Common_TaskResults_CSharp\OnDemandTaskResults\JavaScript\OnDemandTaskResults.js JavaScript file containing the client-side logic needed for attributes-on-demand functionality. Includes extensions to MapTips, GraphicFeature, and TaskResults, as well as implementations of TreeViewPlusNode, TaskResultNode, GraphicFeatureGroupNode, and GraphicFeatureNode.
Download the C# files
Common_TaskResults_VBNet\TaskResultsWebSite\SimpleResult.aspx Illustrates creation of a simple task result.
Common_TaskResults_VBNet\TaskResultsWebSite\SimpleResult.aspx.vb Code behind the .aspx page.
Common_TaskResults_VBNet\TaskResultsWebSite\DataTableResult.aspx Illustrates creation of a task result from a DataTable.
Common_TaskResults_VBNet\TaskResultsWebSite\DataTableResult.aspx.vb Code behind the .aspx page.
Common_TaskResults_VBNet\TaskResultsWebSite\GraphicsLayerResult.aspx Illustrates creation of a task result from a GraphicsLayer.
Common_TaskResults_VBNet\TaskResultsWebSite\GraphicsLayerResult.aspx.vb Code behind the .aspx page.
Common_TaskResults_VBNet\TaskResultsWebSite\ContextMenu.aspx Illustrates the configuration of a custom context menu for task results.
Common_TaskResults_VBNet\TaskResultsWebSite\ContextMenu.aspx.vb Code behind the .aspx page.
Common_TaskResults_VBNet\TaskResultsWebSite\SelectionSet.aspx Illustrates placing task results in a single selected set that is updated when a new selection is made.
Common_TaskResults_VBNet\TaskResultsWebSite\SelectionSet.aspx.vb Code behind the .aspx page.
Common_TaskResults_VBNet\TaskResultsWebSite\App_Code\SelectTool.vb Class containing the implementation of the selection tool.
Common_TaskResults_VBNet\TaskResultsWebSite\ZoomToResultsContainer.aspx Illustrates using a custom TaskResults control to both display and automatically zoom to task results.
Common_TaskResults_VBNet\TaskResultsWebSite\ZoomToResultsContainer.aspx.vb Code behind the .aspx page.
Common_TaskResults_VBNet\ZoomToResults\ZoomToResults.vb Class containing the implementation of a custom TaskResults control that automatically zooms to results.
Common_TaskResults_VBNet\TaskResultsWebSite\ZoomToResultsFilter.aspx Illustrates the use of a custom TaskResults control to automatically zoom to results that are displayed in a separate TaskResults control.
Common_TaskResults_VBNet\TaskResultsWebSite\ZoomToResultsFilter.aspx.vb Code behind the .aspx page.
Common_TaskResults_VBNet\TaskResultsWebSite\TaskResultsPanel.aspx Illustrates a custom task that displays the attributes of results tabularly in a floating panel.
Common_TaskResults_VBNet\TaskResultsWebSite\TaskResultsPanel.aspx.vb Code behind the .aspx page.
Common_TaskResults_VBNet\TaskResultsWebSite\App_Code\TabularResultsTask.vb Class containing a task implementation that displays results in a TaskResultsPanel.
Common_TaskResults_VBNet\TaskResultsWebSite\App_Code\TaskResultsPanel.vb Class containing an extended floating panel implementation for displaying task results tabularly.
Common_TaskResults_VBNet\TaskResultsWebSite\JavaScript\TaskResultsPanel.js JavaScript file containing the client-side implementation of the TaskResultsPanel control.
Common_TaskResults_VBNet\TaskResultsWebSite\OnDemandResults.aspx Illustrates a TaskResults control that has been customized so that attributes for a task result are retrieved only when the result's feature node or MapTip is expanded.
Common_TaskResults_VBNet\TaskResultsWebSite\OnDemandResults.aspx.vb Code behind the .aspx page.
Common_TaskResults_VBNet\OnDemandTaskResults\OnDemandTaskResults.vb Class containing an extended TaskResults implementation that configures task results attributes to be retrieved on demand.
Common_TaskResults_VBNet\OnDemandTaskResults\IAttributesOnDemandProvider.vb Interface specifying the member that must be implemented for an OnDemandTaskResults control to retrieve results from the control that packages the task results. This enables on-demand retrieval of attributes from the GIS data server, rather than from a Web-tier cache.
Common_TaskResults_VBNet\OnDemandTaskResults\JavaScript\OnDemandTaskResults.js JavaScript file containing the client-side logic needed for attributes-on-demand functionality. Includes extensions to MapTips, GraphicFeature, and TaskResults, as well as implementations of TreeViewPlusNode, TaskResultNode, GraphicFeatureGroupNode, and GraphicFeatureNode.
Download the VB.NET files

Download the files for all languages