Creating a Web application with Web controls
Do the following steps:
- Start Visual Studio and create a project.
- Click the File menu, click New, and select Web Site. The New Web Site dialog box appears. See the following screen shot:
- Click the Location drop-down arrow and select Hypertext Transfer Protocol (HTTP).
- Click the Language drop-down arrow and select an applicable language.
- Click ASP.NET Web site under the Visual Studio installed templates area.
- Type a name and location for the Web application, then click OK. A blank Default.aspx page in design view appears.
- Open the Visual Studio Toolbox, expand the ArcGIS Web Controls tab, drag a MapResourceManager control, then a Map control onto the Default.aspx page.
- Set the ResourceItems property on the MapResourceManager control by clicking the Edit Resources verb on the control in design view. Alternatively, you can also click the ellipsis next to the ResourceItems property on the MapResourceManager property page to show the MapResourceItem Collection Editor dialog box. See the following screen shot:
- Click Add to add a new MapResourceItem. Set its Definition property by clicking the ellipsis on the property page to display the Map Resource Definition Editor. Select a resource type and define the appropriate properties. For more information, see the Add Resources section in MapResourceManager control. In general, you can use any resource type that generates a map image.
- Close the MapResourceItem Collection Editor.
- Set the MapResourceManager property on the Map control by selecting the Map control in design view, or in the Properties window clicking the drop-down list for the MapResourceManager property, and selecting the name of the MapResourceManager control added in Step 6 (the default is MapResourceManager1).
- Change the size of the Map control to at least 300 by 300 pixels. This is not required; however, it will make the Map easier to visualize on the page.
- Add a Toc control to the Default.aspx page.
- Change the positioning of the control to be absolute, which enables the control to be placed anywhere on the page. By default, Visual Studio adds controls in flow layout. To change the position do the following:
- In design view, click the Toc control.
- Click the Format menu and click Position. The following Position dialog box appears:
- On the Position dialog box, click Absolute under the Positioning style section, then click OK.
- Select the Toc control in design view and drag it to another location on the page. It immediately displays in the upper left corner of the page. This is default behavior associated with Web control positioning in Visual Studio. Select the Toc control again and drag it to the right of the Map control.
- Set the BuddyControl property on the Toc control by selecting the Toc control in design view or in the Properties window and clicking the drop-down list for the BuddyControl property. The list includes the names of Map controls available on the page. Select the name of the Map control added in Step 6 (the default is Map1). This buddies the Toc with the Map control.
- Add a Toolbar control to the Default.aspx page.
- Set the BuddyControls property on the Toolbar control by selecting the Toolbar control in design view, or in the Properties window and clicking the ellipsis for the BuddyControls property. The BuddyControl Collection Editor dialog box opens.
- Add a new item and set its Name property to the name of the Map control added in Step 6 (the default is Map1).
- Set the ToolbarItems property on the Toolbar control by selecting the Toolbar control in design view, or in the Properties window and clicking the ellipsis for the ToolbarItems property. The ToolbarItems Collection Editor dialog box opens.
- Add all tools under the Navigation Tools node. For more information, see the Add Toolbar Items section in Toolbar control.
- Click OK to exit the ToolbarItems Collection Editor dialog box and save all changes to the Web site. In design view, the site resembles the following:
- Click Start to run the application. Explore the interface of the Web application. For example, click the Zoom In tool on the toolbar and drag a rectangle over the map.
- Click Stop to stop the application and close the browser window.