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 and <Your ArcGIS Developer Kit Install directory>/Samples/data/NorthAmerica (hosted online).
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
- 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.
- In Windows Explorer, navigate to <ArcGIS Developer Kit install location>\Samples\ServerNET. This folder contains the Common_CustomTasks_CSharp and Common_CustomTasks_VBNet folders.
- Open the folder of the language you are going to use (that is, CSharp or VBNet) and copy the Common_CustomTasks_<language> folder to c:\inetpub\wwwroot. The <language> variable can be CSharp or VBNet.
- Open the IIS Manager from Control Panel, Administrative Tools, Internet Information Services (IIS) Manager, or Internet Information Services.
- In the console tree view on the left, navigate to Local Computer, Web Sites, Default Web Site. Expand Default Web Site, open the Common_CustomTasks_<language> folder, right-click the CustomTasksWebSite folder, and click Properties. The Properties dialog box appears.
- Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
- Start Visual Studio 2010 and open solution file for the Common_CustomTasks_CSharp sample Common_CustomTasks_CSharp2010.sln located in the c:\inetpub\wwwroot\Common_CustomTasks_CSharp folder.
- In the Solution Explorer, right-click the CustomTasksWebSite project, and select Set as StartUp Project.
- Right-click the page you want to view and select Set As Start Page.
- The pages in this sample are configured to use the USA and NorthAmerica map services, and it is assumed that USA service is running on the local machine (localhost) while NorthAmerica is accessed online. You can create these services by publishing the map documents located at <ArcGIS Developer Kit install location>\Samples\data. Usa.mxd is in the USA folder. For instructions on how to publish a map document to ArcGIS for Server, see "Publishing a GIS resource to the server" in the ArcGIS for Server Help. The sample also uses the following uniform resource locator (URL) for geometry tasks such as buffer (http://tasks.arcgisonline.com/arcgis/services/Geometry/GeometryServer).
- If these services are running on a remote machine, specify the proper location by opening the page you want to view in Design view, open the properties window for the MapResourceManager control, and click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog box appears.
- Click the ellipsis next to the Definition property. The Map Resource Definition Editor dialog box appears.
- In the Data Source field, replace localhost with the name of the machine hosting the service.
- If necessary, set the run time identity of the Web application by following one of the next two steps. If not necessary, proceed to Step 17.
- At design time, the identity of the user running Visual Studio is used to connect to an ArcGIS for Server local data source. At run time, that identity is established by the Web application. Only one identity can be used to define access to the ArcGIS for Server local data sources in a single Web application. This identity can be explicitly defined when building the Web ADF application in Visual Studio by right-clicking the Web project in the Solution Explorer and selecting the Add ArcGIS Identity option. Add the identity credentials that will be used to access ArcGIS for Server local resources at run time. This information is added to the web.config file in a standard ASP.NET identity tag. If the Encrypt identity in web.config check box is selected, the identity tag will be encrypted; otherwise, the username and password are stored as clear text.
- Open the web.config file and add an <identity> element in <system.web>, set the impersonate attribute to true, add a username and password attribute, and set them to a valid user account. If you are working with ArcGIS for Server local data sources, ensure the account has access to the geographic information system (GIS) server resources referenced in the Map control.
- Save the solution. This sample includes pre-built custom task assemblies, and the appropriate statements in each corresponding .aspx file to load and utilize these custom tasks. To rebuild a custom task control, see the following "Rebuild a custom task control" section.
Rebuild a custom task control
- Each task's source code is in the <task name>_<language> class library project, for example, EmbeddedResourcesTask_CSharp. Build the custom task control by right-clicking the project and selecting Build.
- Open the corresponding Web page in Design view. The name of the corresponding Web page is in the form <task name>WebPage, for example, EmbeddedResourcesTaskWebPage.
- Right-click the General tab on the Visual Studio toolbox, select Choose Items, and navigate to the location of the assembly (<task name>_<language>.dll) generated in the previous step (for example, c:\inetpub\wwwroot\Common_CustomTasks_<language>\CustomTasksWebSite\bin\Debug). A new control reference with the name <task name>_<language> is available in the Visual Studio toolbox.
- If a custom task control has already been added to the TaskManager control in the page, delete it, drag the new task control into the TaskManager, then set its TaskResults container property to the TaskResults1 control on the page.
- Click the Debug drop-down menu and click Start Debugging.
At run time
- Open a browser and add the URL of the page you want to view. For example, http://localhost/Common_CustomTasks_CSharp/CustomTasksWebSite navigates to the root of the sample Web site.
- Use the custom task Web pages as outlined in the following "Async task Web page" section.
Async task Web page
- Access AsyncTaskWebPage.aspx.
- Click the Execute button several times. The task result nodes change from an executing message, to a submitted message, to a succeeded message.
Embedded resources task Web page
- Access EmbeddedResourcesTaskWebPage.aspx.
- Click the Change Image button. The image changes. The images and the JavaScript that changes them were included in the task as embedded resources.
Postback task Web page
- Access PostBackTaskWebPage.aspx.
- The PostBackTask has three buttons that all have similar effects. The instructive part of this example is the different ways those effects are achieved. To see this, place breakpoints and step through the code for each button.
- Add a ScriptManager to the page (enabling partial postbacks) and step through the code again.
Script task Web page
- Access ScriptTaskWebPage.aspx.
- Type the name of a map service running locally into the text box and click Get Layers. The task result appears on the bottom of the task interface. The task execution and interface update are both done through server-side members that have been made scriptable.
- Type something that is not the name of a map service and click Get Layers. An error message appears on the task interface.
Query builder task Web page
- Access QueryBuilderTaskWebPage.aspx.
- Change the layer. Note the cascading changes to the Fields and Sample Values. This behavior is initiated via scriptable server-side members.
- Change the field. The Sample Values are updated.
- Click the Add to Query button. The selected values in the drop-down lists have been turned into a query expression and placed in the Query text box.
- Click the Execute Query button. The results display.
- Click Switch Maps in the upper right corner of the page. The task's drop-down lists are updated with information pertaining to the California service.
Find near task Web page
- Access FindNearTaskWebPage.aspx.
- Click the Define search area by point tool, and click a point on the map.
- Change the units to miles. The search area is updated.
- Change the search distance to 300. The search area is updated.
- Click the Define search area by polyline tool, click several points on the map to draw a polyline, and double-click when finished. The search area is updated to include a buffer around the polyline.
- Click the Define search area by polygon tool, draw the polygon on the map, and double-click when finished. The search area is updated to include a buffer around the polygon.
- Click Find on the Query Counties task. The task executes and finds six counties.
- In the TaskResults control, click the Query Counties node, then click the Counties child node. The feature nodes for the six counties that were found appear.
- On FindNearTask, select the tool to specify the search area by task result.
- Click one of the county task result nodes. The search area updates to include a buffer around the county corresponding to the node that was clicked.
- Click the tool to define a search area by selecting features from the map.
- In the drop-down list that appears, choose States as the selection layer.
- On the map, click and drag a small box over a few states. The search area is updated with a buffer around the selected states.
- From the Search Layer drop-down list, select States.
- Click the Find button. The states intersecting the buffer are selected and the task results appear in a floating panel.
- On FindNearTask, click the command to clear input features from the map. Input features and buffers are removed, but the task results remain.
FindNearUserControltask Web page
- Access FindNearUserControlTaskWebPage.aspx.
- All the functionality is same as provided by the Find Near task Web page. The only difference is that the Find Near task on this page is a user control task that is plugged into the out-of-the box UserControlTask control.
Optimize task Web page
- Access OptimizerTaskWebPage.aspx.
- Add a value in the text box in the task, and click the button to execute the task. The task iterates through the CreateChildControls method and generates output for the TaskResults control.
- Click a tool in the toolbar to zoom in or out on the map.
- Apply the tool in the map. The child controls for the task are not created (step through the code in debug mode to view this).
- Click the callback or partial postback button in the task. The task iterates through the CreateChildControls method and processes the async request. The map zooms in by a factor of two (2). Even though the task did not process the async request, one of its child controls did, so iterating through CreateChildControls was necessary.
Common_CustomTasks_CSharp\AsyncTask_CSharp\AsyncTask_CSharp.csproj | Class library project file for the AsyncTask control. |
Common_CustomTasks_CSharp\AsyncTask_CSharp\BasicAsyncTask.cs | AsyncTask implementation code. |
Common_CustomTasks_CSharp\CustomTasksWebSite\AsyncTaskWebPage.aspx | User interface (UI) for the Web application. |
Common_CustomTasks_CSharp\CustomTasksWebSite\AsyncTaskWebPage.aspx.cs | Code behind the UI. |
Common_CustomTasks_CSharp\EmbeddedResourcesTask_CSharp\EmbeddedResourcesTask_CSharp.csproj | Class library project file for the EmbeddedResourcesTask control. |
Common_CustomTasks_CSharp\EmbeddedResTask_CSharp\EmbeddedResourcesTask.cs | EmbeddedResourcesTask implementation code. |
Common_CustomTasks_CSharp\EmbeddedResTask_CSharp\Resources\JS\CustomJavaScript.js | Embedded JavaScript for switching images. |
Common_CustomTasks_CSharp\CustomTasksWebSite\EmbeddedResourcesTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_CSharp\CustomTasksWebSite\EmbeddedResourcesTaskWebPage.aspx.cs | Code behind the UI. |
Common_CustomTasks_CSharp\PostBackTask_CSharp\PostBackTask_CSharp.csproj | Class library project file for the PostBackTask control. |
Common_CustomTasks_CSharp\PostBackTask_CSharp\PostBackTask.cs | PostBackTask implementation code. |
Common_CustomTasks_CSharp\PostBackTask_CSharp\Resources\JavaScript\CustomSendRequest.js | JavaScript for sending a custom request to the server. |
Common_CustomTasks_CSharp\CustomTasksWebSite\PostBackTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_CSharp\CustomTasksWebSite\PostBackTaskWebPage.aspx.cs | Code behind the UI. |
Common_CustomTasks_CSharp\ScriptTask_CSharp\ScriptTask_CSharp.csproj | Class library project file for the ScriptTask control. |
Common_CustomTasks_CSharp\ScriptTask_CSharp\ScriptTask.cs | ScriptTask implementation code. Super class for scriptable tasks. |
Common_CustomTasks_CSharp\ScriptTask_CSharp\SimpleScriptTask.cs | SimpleScriptTask implementation code. Sub-classes ScriptTask. |
Common_CustomTasks_CSharp\CustomTasksWebSite\ScriptTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_CSharp\CustomTasksWebSite\ScriptTaskWebPage.aspx.cs | Code behind the UI. |
Common_CustomTasks_CSharp\QueryBuilderTask_CSharp\QueryBuilderTask_CSharp.csproj | Class library project file for the QueryBuilderTask control. |
Common_CustomTasks_CSharp\QueryBuilderTask_CSharp\QueryBuilderTask.cs | QueryBuilderTask implementation code. |
Common_CustomTasks_CSharp\QueryBuilderTask_CSharp\QueryBuilderTask.js | Client functions for QueryBuilderTask. |
Common_CustomTasks_CSharp\CustomTasksWebSite\QueryBuilderTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_CSharp\CustomTasksWebSite\QueryBuilderTaskWebPage.aspx.cs | Code behind the UI. |
Common_CustomTasks_CSharp\FindNearTask_CSharp\FindNearTask_CSharp.csproj | Class library project file for the FindNearTask control. |
Common_CustomTasks_CSharp\FindNearTask_CSharp\FindNearTask.cs | FindNearTask implementation code. |
Common_CustomTasks_CSharp\FindNearTask_CSharp\Tools.cs | Implementation of input specification tools. |
Common_CustomTasks_CSharp\FindNearTask_CSharp\TaskResultsPanel.cs | FloatingPanel implementation for displaying task results in a table. |
Common_CustomTasks_CSharp\FindNearTask_CSharp\InputParameters.cs | Manages input parameters for Find Near operations. |
Common_CustomTasks_CSharp\FindNearTask_CSharp\GraphicsResource.cs | Manages the graphics resource used to display task input geometries. |
Common_CustomTasks_CSharp\FindNearTask_CSharp\TabularResultOptions.cs | Options for displaying task results. |
Common_CustomTasks_CSharp\FindNearTask_CSharp\Resources\javascript\FindNearTask.js | Client functions for FindNearTask. |
Common_CustomTasks_CSharp\FindNearTask_CSharp\Resources\javascript\TaskResultsPanel.js | Client functions for TaskResultsPanel. |
Common_CustomTasks_CSharp\CustomTasksWebSite\FindNearTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_CSharp\CustomTasksWebSite\FindNearTaskWebPage.aspx.cs | Code behind the UI. |
Common_CustomTasks_CSharp\OptimizeTask_CSharp\OptimizeTask_CSharp.csproj | Class library project file for the OptimizeTask control. |
Common_CustomTasks_CSharp\OptimizeTask_CSharp\OptimizeTask.cs | OptimizeTask implementation code. Notable entries are present in the CreateChildControls method. |
Common_CustomTasks_CSharp\OptimizeTask_CSharp\AsyncOptimizer.cs | Optimizer utility class. |
Common_CustomTasks_CSharp\CustomTasksWebSite\OptimizeTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_CSharp\CustomTasksWebSite\OptimizeTaskWebPage.aspx.cs | Code behind the UI. |
Common_CustomTasks_VBNet\AsyncTask_VBNet\AsyncTask_VBNet.vbproj | Class library project file for the AsyncTask control. |
Common_CustomTasks_VBNet\AsyncTask_VBNet\BasicAsyncTask.vb | AsyncTask implementation code. |
Common_CustomTasks_VBNet\CustomTasksWebSite\AsyncTaskWebPage.aspx | User interface (UI) for the Web application. |
Common_CustomTasks_VBNet\CustomTasksWebSite\AsyncTaskWebPage.aspx.vb | Code behind the UI. |
Common_CustomTasks_VBNet\EmbeddedResourcesTask_VBNet\EmbeddedResourcesTask_VBNet.vbproj | Class library project file for the EmbeddedResourcesTask control. |
Common_CustomTasks_CSharp\EmbeddedResTask_CSharp\EmbeddedResourcesTask.vb | EmbeddedResourcesTask implementation code. |
Common_CustomTasks_VBNet\EmbeddedResTask_VBNet\Resources\JS\CustomJavaScript.js | Embedded JavaScript for switching images. |
Common_CustomTasks_VBNet\CustomTasksWebSite\EmbeddedResourcesTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_VBNet\CustomTasksWebSite\EmbeddedResourcesTaskWebPage.aspx.vb | Code behind the UI. |
Common_CustomTasks_VBNet\PostBackTask_VBNet\PostBackTask_VBNet.vbproj | Class library project file for the PostBackTask control. |
Common_CustomTasks_VBNet\PostBackTask_VBNet\PostBackTask.vb | PostBackTask implementation code. |
Common_CustomTasks_VBNet\PostBackTask_VBNet\Resources\JavaScript\CustomSendRequest.js | JavaScript for sending a custom request to the server. |
Common_CustomTasks_VBNet\CustomTasksWebSite\PostBackTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_VBNet\CustomTasksWebSite\PostBackTaskWebPage.aspx.vb | Code behind the UI. |
Common_CustomTasks_VBNet\ScriptTask_VBNet\ScriptTask_VBNet.vbproj | Class library project file for the ScriptTask control. |
Common_CustomTasks_VBNet\ScriptTask_VBNet\ScriptTask.vb | ScriptTask implementation code. Super class for scriptable tasks. |
Common_CustomTasks_VBNet\ScriptTask_VBNet\SimpleScriptTask.vb | SimpleScriptTask implementation code. Sub-classes ScriptTask. |
Common_CustomTasks_VBNet\CustomTasksWebSite\ScriptTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_VBNet\CustomTasksWebSite\ScriptTaskWebPage.aspx.vb | Code behind the UI. |
Common_CustomTasks_VBNet\QueryBuilderTask_VBNet\QueryBuilderTask_VBNet.vbproj | Class library project file for the QueryBuilderTask control. |
Common_CustomTasks_VBNet\QueryBuilderTask_VBNet\QueryBuilderTask.vb | QueryBuilderTask implementation code. |
Common_CustomTasks_VBNet\QueryBuilderTask_VBNet\QueryBuilderTask.js | Client functions for QueryBuilderTask. |
Common_CustomTasks_VBNet\CustomTasksWebSite\QueryBuilderTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_VBNet\CustomTasksWebSite\QueryBuilderTaskWebPage.aspx.vb | Code behind the UI. |
Common_CustomTasks_VBNet\FindNearTask_VBNet\FindNearTask_VBNet.vbproj | Class library project file for the FindNearTask control. |
Common_CustomTasks_VBNet\FindNearTask_VBNet\FindNearTask.vb | FindNearTask implementation code. |
Common_CustomTasks_VBNet\FindNearTask_VBNet\Tools.vb | Implementation of input specification tools. |
Common_CustomTasks_VBNet\FindNearTask_VBNet\TaskResultsPanel.vb | FloatingPanel implementation for displaying task results in a table. |
Common_CustomTasks_VBNet\FindNearTask_VBNet\InputParameters.vb | Manages input parameters for Find Near operations. |
Common_CustomTasks_VBNet\FindNearTask_VBNet\GraphicsResource.vb | Manages the graphics resource used to display task input geometries. |
Common_CustomTasks_VBNet\FindNearTask_VBNet\TabularResultOptions.vb | Options for displaying task results. |
Common_CustomTasks_VBNet\FindNearTask_VBNet\Resources\javascript\FindNearTask.js | Client functions for FindNearTask. |
Common_CustomTasks_VBNet\FindNearTask_VBNet\Resources\javascript\TaskResultsPanel.js | Client functions for TaskResultsPanel. |
Common_CustomTasks_VBNet\CustomTasksWebSite\FindNearTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_VBNet\CustomTasksWebSite\FindNearTaskWebPage.aspx.vb | Code behind the UI. |
Common_CustomTasks_VBNet\OptimizeTask_VBNet\OptimizeTask_VBNet.vbproj | Class library project file for the OptimizeTask control. |
Common_CustomTasks_VBNet\OptimizeTask_VBNet\OptimizeTask.vb | OptimizeTask implementation code. Notable entries are present in the CreateChildControls method. |
Common_CustomTasks_VBNet\OptimizeTask_VBNet\AsyncOptimizer.vb | Optimizer utility class. |
Common_CustomTasks_VBNet\CustomTasksWebSite\OptimizeTaskWebPage.aspx | UI for the Web application. |
Common_CustomTasks_VBNet\CustomTasksWebSite\OptimizeTaskWebPage.aspx.vb | Code behind the UI. |
Download the files for all languages