Common QueryNewWindow


Purpose
This sample demonstrates how to use a Web Application Developer Framework (ADF) MapResourceManager control and map resources to query a feature layer, and display attribute values in a GridView on another page. To use map resources in a MapResourceManager without another control (for example, the Map control), the resource manager and each resource item must be initialized at run time. If the map resource supports queries, you can work with the generic Common Data Source application programming interface (API), Common API, IQueryFunctionality instead of a specific data source implementation. In this case, you can call the Query method on IQueryFunctionality and work with Web ADF and Common API classes and properties.

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 Developer Kit install location>\Samples\ServerNET. This folder contains the Common_QueryNewWindow CSharp and VBNet folders.
  3. Open the folder of the language you are going to use (that is, CSharp or VBNet) and copy the Common_QueryNewWindow_<language> folder to c:\inetpub\wwwroot. The <language> variable can be 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_QueryNewWindow_<language> folder and click Properties. The Properties dialog box appears.
  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 Visual Studio 2010 and open the Common_QueryNewWindow_<language><vs_version> solution (for example, Common_QueryNewWindow_CSharp2010.sln) located in c:\inetpub\wwwroot\Common_QueryNewWindow_<language>.
  8. In the Solution Explorer, right-click Default.aspx, and select Set As Start Page.
  9. Open the Default.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 appears.
  10. Add or change the MapResourceItem associated with a map service (for example, ArcGIS for Server, ArcIMS, and so on).
  11. Open the code file for the Default.aspx page (for example, Default.aspx.cs), and set the layer name in the resource, the field list to return, and the WHERE clause. By default, the values are respectively; States, STATE_NAME, and STATE_NAME LIKE 'A%'. If necessary, modify the field name alias for the first column. The default is STATE_NAME_ALIAS.
  12. 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 15.
  13. 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.
  14. Open the web.config file, 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.
  15. Save the project.
  16. 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_QueryNewWindow_CSharp.
  2. Click the Open Query Results Window button. A new browser window appears with a table containing the queried attributes.

Common_QueryNewWindow_CSharp\Default.aspx User interface (UI) for the Web application.
Common_QueryNewWindow_CSharp\Default.aspx.cs Code behind the UI.
Common_QueryNewWindow_CSharp\TableDialog.aspx UI for the query results.
Common_QueryNewWindow_CSharp\TableDialog.aspx.cs Code behind the UI.
Download the C# files
Common_QueryNewWindow_VBNet\Default.aspx User interface (UI) for the Web application.
Common_QueryNewWindow_VBNet\Default.aspx.vb Code behind the UI.
Common_QueryNewWindow_VBNet\TableDialog.aspx UI for the query results.
Common_QueryNewWindow_VBNet\TableDialog.aspx.vb Code behind the UI.
Download the VB.NET files

Download the files for all languages

See Also:

MapResourceManager control