Creating a Web application with Web controls
- Start Visual Studio 2008 and create a new project.
- Click the file menu, click New, and select Web Site. The New Web Site dialog box opens as shown in the following screen shot:
- Set the Location value to HTTP and the Language value to your language of choice.
- Under Visual Studio installed templates, click ASP.NET Web Site.
- Type a name and location for the Web application and click OK. Visual Studio 2008 opens a blank Default.aspx page in design view.
- Open the Visual Studio Toolbox, expand the ArcGIS Web Controls tab, and drag a MapResourceManager control and 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 the design view. Alternatively you can also click on the ellipsis next to the ResourceItems property on the MapResourceManager property page to display the MapResourceItem Collection Editor dialog box. See screenshot below.
- 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. See the Add Resources section in the MapResourceManager control topic for more information. 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 300x300 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 2008 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 will immediately display in the upper left corner of the page. This is default behavior associated with Web control positioning in Visual Studio 2008. 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. See the Add Toolbar Items section in the Toolbar control topic for more information.
- Click OK to exit the ToolbarItems Collection Editor dialog box editor and save all changes to the Web site. In design view, the site should appear as follows:
- 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.