Common Add dynamic data


Purpose
This sample demonstrates how to add dynamic resources to a Web Application Developer Framework (ADF) MapResourceManager, map, and table of contents (TOC). This sample accomplishes this process asynchronously using the following techniques:
  • Callback
  • Data items with a partial postback
  • Script blocks with a partial postback
The following types of resources are presented:
  • ArcGIS Server local
  • ArcGIS Server Internet
  • ArcIMS

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 appropriate resources are available (see the Purpose section).
  2. 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.
  3. In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit10.0\Samples\ServerNET. This folder contains Common_AddDynamicData CSharp and VBNet folders.
  4. Open the folder of the language you're going to use—CSharp or VBNet—and copy the Common_AddDynamicData_<language> folder to c:\inetpub\wwwroot. The <language> variable can be either CSharp or VBNet.
  5. Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services.
  6. 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_AddDynamicData_<language> folder, and click Properties. The Properties dialog box opens.
  7. Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
  8. Start Microsoft Visual Studio 2008 or 2010 and open the Common_AddDynamicData_<language><vs_version> solution (for example, Common_AddDynamicData_CSharp2008.sln) located in c:\inetpub\wwwroot\Common_AddDynamicData_<language>. The <vs_version> references the Visual Studio version of the solution, either 2008 or 2010.
  9. In Solution Explorer, right-click a .aspx page and select Set As Start Page.
  10. Open the .aspx page 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 opens.
  11. Add or change the MapResourceItem to a resource with an extent that will contain the dynamic resource to be added.
  12. Open the code file for the .aspx page (for example, Callout.aspx.cs).
  13. In the MapResourceChange method, change the properties of the ArcGIS Server local, ArcGIS Server Internet, and ArcIMS resources to values that will work with services to which you have access.
  14. 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.
  15. At design time, the identity of the user running Visual Studio is used to connect to an ArcGIS 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 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 Solution Explorer and selecting the Add ArcGIS Identity option. Enter the identity credentials that will be used to access ArcGIS 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 checked, the identity tag will be encrypted; otherwise, the username and password are stored as clear text.
  16. Open the web.config file, add an <identity> element in <system.web>, set the impersonate attribute to true, and add a username and password attribute and set them to a valid user account. If you're working with ArcGIS Server local data sources, ensure the account has access to the geographic information system (GIS) server resources referenced in the Map control.
  17. Save the project.
  18. Click the Debug drop-down menu and click Start Debugging.

At run time
  1. Browse to the viewer uniform resource locator (URL) (for example, http://localhost/Common_AddDynamicData_CSharp) or start the Web application in Visual Studio version your are working on.
  2. Select a resource to add. An activity indicator below the Map control shows the application adding the resource. When finished, the new resource is displayed in the map and the TOC.
  3. Uncheck a resource check box. The unchecked resource is removed from the map and the TOC.

Common_AddDynamicData_CSharp\Callback.aspx Illustrates the callback pattern for adding dynamic resources.
Common_AddDynamicData_CSharp\Callback.aspx.cs Code behind the .aspx file. Adds and removes resources from Web ADF controls.
Common_AddDynamicData_CSharp\DynamicDataWithContextMenu.aspx Contains Web controls and custom JavaScript to process dynamic resource requests.
Common_AddDynamicData_CSharp\DynamicDataWithContextMenu.aspx.cs Code behind the .aspx file. Adds and removes resources from Web ADF controls.
Common_AddDynamicData_CSharp\PartialPostback_RegisterDataItem.aspx Illustrates the data item technique for managing dynamic resources in a partial postback solution.
Common_AddDynamicData_CSharp\PartialPostback_RegisterDataItem.aspx.cs Code behind the .aspx file. Adds and removes resources from Web ADF controls.
Common_AddDynamicData_CSharp\PartialPostback_RegisterScriptBlock.aspx Illustrates the script block technique for managing dynamic resources in a partial postback solution.
Common_AddDynamicData_CSharp\PartialPostback_RegisterScriptBlock.aspx.cs Code behind the .aspx file. Adds and removes resources from Web ADF controls.
Download the C# files
Common_AddDynamicData_VBNet\Callback.aspx Illustrates the callback pattern for adding dynamic resources.
Common_AddDynamicData_VBNet\Callback.aspx.vb Code behind the .aspx file. Adds and removes resources from Web ADF controls.
Common_AddDynamicData_VBNet\DynamicDataWithContextMenu.aspx Contains Web controls and custom JavaScript to process dynamic resource requests.
Common_AddDynamicData_VBNet\DynamicDataWithContextMenu.aspx.vb Code behind the .aspx file. Adds and removes resources from Web ADF controls.
Common_AddDynamicData_VBNet\PartialPostback_RegisterDataItem.aspx Illustrates the data item technique for managing dynamic resources in a partial postback solution.
Common_AddDynamicData_VBNet\PartialPostback_RegisterDataItem.aspx.vb Code behind the .aspx file. Adds and removes resources from Web ADF controls.
Common_AddDynamicData_VBNet\PartialPostback_RegisterScriptBlock.aspx Illustrates the script block technique for managing dynamic resources in a partial postback solution.
Common_AddDynamicData_VBNet\PartialPostback_RegisterScriptBlock.aspx.vb Code behind the .aspx file. Adds and removes resources from Web ADF controls.
Download the VB.NET files

Download the files for all languages