Common Query New Window


This sample illustrates how to use a Web ADF MapResourceManager control and map resources to query a feature layer and display attribute values in a GridView in another page. To use map resources in a MapResourceManager without another control (e.g. Map) the resource manager and each resource must be initialized at runtime. If the map resource supports queries, you can work with the generic Common API interface 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.
Server: C#, VB.NET

Platforms: Windows

Minimum ArcGIS Release: 9.2

How to use:
  1. 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 install location>\DeveloperKit\SamplesNet\Server\Web_Applications and unzip or to a location of your choice. You should see either a CSharp or VBNet folder appear where you unzipped the files.
    3. In Windows Explorer, open the directory referencing the language of your choice: CSharp or VBNet. Copy the folder, Common_QueryNewWindow_<language>, to c:\inetpub\wwwroot. The <language> variable may be either 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.
    6. Expand Default Web Site then right-click the Common_QueryNewWindow_<language> folder and click Properties.
    7. On the Directory tab, click the Create button in the Application Settings section of this panel. Click OK to dismiss the Properties dialog.
    8. Launch Microsoft Visual Studio 2005 and open the Common_QueryNewWindow_<language> solution (for example, Common_QueryNewWindow_CSharp.sln) located in c:\inetpub\wwwroot\Common_QueryNewWindow_<language>.
    9. In the Solution Explorer, right-click Default.aspx and select 'Set As Start Page'.
    10. Open the Default.aspx page in design view. Open the properties window for the MapResourceManager control. Click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog should display.
    11. Add or change the MapResourceItem associated with a map service (ArcGIS Server, ArcIMS, ArcWeb, etc.).
    12. Open the codefile for the Default.aspx page (e.g. Default.aspx.cs). 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%'".
    13. If necessary, modify the field name alias for the first column. The default is "STATE_NAME_ALIAS".
    14. If necessary, set the runtime identity of the Web application:
      1. At design-time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At runtime, that identity is established by the Web application. Only one identity can be used to define access to all 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 which will be used to access ArcGIS Server local resources at runtime. This information will be added to the web.config file within a standard ASP.NET identity tag. If the "Encrypt identity in web.config" checkbox is checked, the identity tag will be encrypted, otherwise the username and password will be stored as clear text.
      2. Open the web.config file and add an <identity> element within <system.web>. Set the impersonate attribute to "true". Add a userName and password attribute and set them to a valid user account. If working with ArcGIS Server Local data sources, make sure the account has access to the GIS Server resources referenced in the Map control.
    15. Save the project.
    16. Click the "Debug" drop-down menu and choose "Start".
  2. Run Time:
    1. Browse to viewer's URL (for example, http://localhost/Common_QueryNewWindow_CSharp).
    2. Click the Open Query Results Window button. A new browser window should display with a table containing the queried attributes.

Download the C# files
Common_QueryNewWindow_CSharp.sln The solution file.
Default.aspx User interface for the Web application
Common_QueryNewWindow_CSharp/Default.aspx.cs The code behind the user interface
TableDialog.aspx User interface for the query results.
Common_QueryNewWindow_CSharp/TableDialog.aspx.cs The code behind the user interface
Download the VB.NET files
Common_QueryNewWindow_VBNet.sln The solution file.
Default.aspx User interface for the Web application
Common_QueryNewWindow_VBNet/Default.aspx.vb The code behind the user interface
TableDialog.aspx User interface for the query results.
Common_QueryNewWindow_VBNet/TableDialog.aspx.vb The code behind the user interface

Download the files for all languages