SearchAttributesTask control


In this topic


About the SearchAttributesTask control

Use the SearchAttributesTask control to select a set of fields in feature layers provided by resources and search for a user-provided value. At run time, each field is queried for the occurrence of a value provided by the user (partial values are permitted). Only feature layers in resources provided by a MapResourceManager can be used. Feature layers must have unique layer names to work with the SearchAttributesTask. The results are provided as an ADO.NET dataset to display in a TaskResults control.  

Using the control

Do the following to use the control:
  1. Add supporting controls to the page. Set up a Web application with MapResourceManager and Map controls. Add a TaskManager, Menu, and TaskResults control. At run time, the TaskResults control displays the results of the SearchAttributesTask. You can then interact with the results to change map extent, display selected features, or re-execute the task. 
  2. To add a SearchAttributesTask control, in Visual Studio, open the prepared Web form in design mode, select the Toolbox panel, and expand the ArcGIS Web Controls tab. Drag and drop a SearchAttributesTask control into the TaskManager control. See the following screen shot that shows the page in Visual Studio:


  3. To set properties for the SearchAttributesTask control, in design mode, click the SearchAttributesTask control, which shows the smart tag arrow in the upper right corner of the control (shows the verbs associated with the control). See the following screen shot:


    1. Buddy the task control with the TaskResults control to display the results of a task. Click the Choose Task Results container verb on the preceding screen shot to modify the TaskResultsContainers property. The BuddyControl Collection Editor dialog box appears. Click Add to add an item and select the ID of the TaskResults control you want to display in the task results. See the following screen shot:


    2. To configure the task, click Choose Search Fields on the smart tag menu to edit search attribute properties. The Search Attributes Properties dialog box appears displaying three tabs (General, Settings, and Results). Use the settings on these tabs to change the visible content on the task at run time, set the search fields, and customize the results that display. 
      • General tab—Use to change the task control name as it appears in the ASP.NET Navigation control (for example, Menu), the button text on the button to execute the task, and Help Tip text to provide assistance at run time. 

        See the following screen shot that shows the Search Attributes Properties dialog box with the General tab selected: 


      • Settings tab—Use to choose the fields you want to search. Select from a list of fields in feature layers in map resources. Only string fields can be searched. Each field in each layer is searched for the occurrence of a user-provided string. 

        See the following screen shot that shows the Search Attributes Properties dialog box with the Settings tab selected:   


      • Results tab—Use to define how the results of a query are returned and shown to the client. It works explicitly with the capabilities of a TaskResults control.  
        • Limit search results to—Use to set the maximum number of records returned in the result. If more records are returned from a search, paging is enabled on the records rendered in the TaskResults container.  
        • Group results by layer name in Results Panel—Select the check box to group results from a query in the TaskResults. If selected (the default), results from a query are contained in a parent node to display in the TaskResults. The parent node will have the same name as the queried layer and the number of records returned. If the check box is not selected, each result record is added to the TaskResults control independently. 
        • Show attributes in Results Panel—Select this check box to show attributes for each returned record. If selected (the default), attributes for each returned record from a search display in the TaskResults control. If the check box is not selected, only the primary display field shows for each record node.
        • Show MapTips—Choose to show MapTips on the results displayed on the map. If selected (the default), callouts for MapTips are available for graphic results on the map.
        • Display Results Using—Choose one of the following formats to display results: 
          • Layer formatting—Defined for the map resource item that contains the queried layer is used by default. 
          • Custom formatting—You can choose to customize the format (symbology, fields, and attribute display) of results. 
        • Layer—Use to select a layer type from the drop-down list.
        • Symbols tab—Use to define the default and highlight symbol for results generated by the query. Click the Draw with or Highlight with button to change the symbol. When results are generated from search layers at run time, features will render in the Web browser using the default (Draw with) symbol. When the mouse pointer hovers over a feature, the highlight symbol (Highlight with) appears. The layer's feature type determines the options to change the symbol.
        See the following screen shot that shows the Search Attributes Properties dialog box with the Results and Symbols tab selected:


        • Fields tab—Shows the fields in the search layer. Click the Primary display field drop-down arrow to select the primary display field for attribute tables. This area can be used to describe the contents of a record and is set to a field that contains an intuitive, preferably unique value to identify an attribute. Select a check box next to each field to set the field's visibility. You can also edit the text in the Alias field if you do not want to use the original field name. Results generated from searching a layer contain only visible fields and use field aliases to define column names. 

          The Primary display field will be used to define the node text for each record shown in a TaskResults control. For data sources that do not provide field settings, all fields are visible by default and the alias is the same as the field name. The Primary display field is set to the first string field with "name" in it. If this field is not found, the first string field is used. If there are no string fields, the first numeric field is used. 

          See the following screen shot that shows the Fields tab:


        • Records tab—Displays the tabular format of results shown in the Web browser at run time. Record display properties for the query layer can be used to show results in a TaskResults control or in a MapTips callout window. By default, visible fields are included in the record display as name value pairs and the title is the primary display field.

          To customize the record display, click the Custom formatting radio button. The Title and Contents sections on the dialog box are now editable. The Contents section provides a rich text editor to modify font style and color, or to add fields, hyperlinks, tables, or images. Edits are stored as Hypertext Markup Language (HTML) style content to render in the Web browser at run time. To view the HTML content that will be used to format layer results, click the HTML radio button on the bottom of the dialog box. The raw HTML content displays in the Contents window. Any valid content to render in a Web browser can be added, including HTML, Cascading Style Sheets (CSS) definitions, and JavaScript.

          See the following screen shot that shows the Records tab:


    3. Set the Visible property to false so the SearchAttributesTask control does not immediately display at run time. When the menu item that is generated by the output is clicked from the TaskManager, the task control displays.
  4. Run the application and execute the task. At run time, click the My Search Attributes Task menu item. The SearchAttributesTask dialog box appears. Type a string value you expect to be in the selected search fields, then click Find. 

    The following screen shot shows the task searching the US States layer for state names that contain the text "New." When a task is executed at run time, the TaskResults control displays an animated .gif to indicate that the task is working. Click Cancel to exit the task before it completes. The arrow indicates the location of the task execution indicator in the TaskResults control.

  1. When SearchAttributesTask execution completes, the results are returned in the TaskResults control in a tree view. You can expand and collapse the branches of the results collection to view result items. If attributes are returned, you can expand its node to view feature attribute values. If the check box next to a feature node is selected, the feature will be selected on the map (by default, all are selected). If you hover the pointer over the feature node in the TaskResults control or the feature on the map, the feature will be highlighted. The following screen shot shows the mouse pointer hovering over the New Mexico feature node in the TaskResults control, which highlights the state of New Mexico on the map.


  2. To use the context menu on the result items, right-click the result items. The context menu appears with the following options:
    • Zoom to—Zooms to the result item on the map.
    • Pan to—Pans the map to center on the result item.
    • Remove—Eliminates the result item from the task results list.

      See the following screen shot:


  3. To use the context menu on the task results, right-click to display the context menu. The context menu appears with the following options:
    • Rerun task—Executes the same task again and updates this task result collection.
    • Remove—Eliminates this task results collection from the TaskResults control.

      See the following screen shot: 

Members

The following table shows a list of properties related to the SearchAttributesTask control. For more information, see the SearchAttributesTask control in the Library Reference section.
Property name
Type
Description
ButtonText
string
Text that appears on the button to execute the task.
DefaultValue
string
Default text search value.
FindOption
FindOption
Whether to search all layers specified in the task (AllLayers) or only layers currently visible (VisibleLayers).
FeatureSelectionColor
color
Color of the selected features.
InputWidth
unit
Width of the text box in which the user types the value to search.
GroupResultsByTable
bool
Whether the results of this task have the results grouped by layers.
LabelText
string
Text that shows next to the input box indicating the name of the value to type.
MaxRecords
int
Maximum number of records the task returns. The value can be limited by the service underlying the map resource. For example, by default, ArcGIS for Server map services are limited to returning 500 features at a time. To change this value, modify the MaxRecordCount property in the service configuration file (.cfg). For more information, see Service configuration files.
NavigationPath
string
Path to the task as it appears in a hierarchical data control buddied to the task's TaskManager.
SearchFields
string
List of map resource layer fields on which a search for a value is made.
ShowFieldAttributes
bool
Whether the results of this task will have the field attributes.
ShowLegend
bool
Legend is available if GroupResultsByTable is set to true.
TaskResultsContainers
BuddyControlCollection
Controls in which results from the task display.
Title
string
Text shown on the panel's title bar.


See Also:

Service configuration files
Web controls
Customizing the Web Mapping Application




To use the code in this topic, reference the following assemblies in your Visual Studio project. In the code files, you will need using (C#) or Imports (VB .NET) directives for the corresponding namespaces (given in parenthesis below if different from the assembly name):
  • ESRI.ArcGIS.ADF.Tasks.dll