ADFTutorials_VBNet\UsingCommonAPI\Default.aspx.vb
' Copyright 2011 ESRI ' ' All rights reserved under the copyright laws of the United States ' and applicable international laws, treaties, and conventions. ' ' You may freely redistribute and use this sample code, with or ' without modification, provided you include the original copyright ' notice and use restrictions. ' ' See the use restrictions. ' Imports Microsoft.VisualBasic Imports System Imports System.Data Imports System.Configuration Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Imports System.Web.UI.HtmlControls Public Partial Class _Default Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal eventArgs As EventArgs) ' Store the TaskResults control in session for use by the custom tool Session("TaskResultsControl") = TaskResults1 ' Add a handler for the resource drop-down's SelectedIndexChanged event AddHandler DropDownList1.SelectedIndexChanged, AddressOf DropDownList1_SelectedIndexChanged End Sub Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal eventArgs As EventArgs) ' Clear the layers drop-down DropDownList2.Items.Clear() ' Get the names of queryable layers for the selected resource and add them ' to the layers drop-down Dim layerNames As String() = GetQueryableLayerNames(DropDownList1.SelectedItem.Text) Dim i As Integer = 0 Do While i < layerNames.Length DropDownList2.Items.Add(layerNames(i)) i += 1 Loop End Sub Protected Sub Page_PreRender(ByVal sender As Object, ByVal eventArgs As EventArgs) If DropDownList1.Items.Count = 0 Then ' Add resource names to the resource drop-down list For Each mapResourceItem As ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem In MapResourceManager1.ResourceItems DropDownList1.Items.Add(mapResourceItem.Resource.Name) Next mapResourceItem ' Get the names of queryable layers for the selected resource and add them ' to the layers drop-down Dim layerNames As String() = GetQueryableLayerNames(DropDownList1.SelectedItem.Text) Dim i As Integer = 0 Do While i < layerNames.Length DropDownList2.Items.Add(layerNames(i)) i += 1 Loop End If End Sub Private Function GetQueryableLayerNames(ByVal resourceName As String) As String() ' Get a reference to the resource Dim commonMapFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality = Map1.GetFunctionality(resourceName) Dim gisResource As ESRI.ArcGIS.ADF.Web.DataSources.IGISResource = commonMapFunctionality.Resource ' Create a query functionality to use in querying the resource Dim commonQueryFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality = CType(gisResource.CreateFunctionality(GetType(ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality), Nothing), ESRI.ArcGIS.ADF.Web.DataSources.IQueryFunctionality) ' Get the resource's queryable layers Dim layerIDs As String() = Nothing Dim layerNames As String() = Nothing commonQueryFunctionality.GetQueryableLayers(Nothing, layerIDs, layerNames) Return layerNames End Function End Class