Common_MapTips_VBNet\SetMapTipsLayer.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 Partial Public Class _SetMapTipsLayer Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) If (Not Page.IsPostBack) Then ' Retrieve the Web ADF DropDownBox that we wish to populate with layer names Dim dropDownBox As ESRI.ArcGIS.ADF.Web.UI.WebControls.DropDownBox = TryCast(Toolbar1.ToolbarItems.Find("DropDownBox0"), ESRI.ArcGIS.ADF.Web.UI.WebControls.DropDownBox) ' Make sure the DropDownBox is empty and add an item instructing the user to select a layer dropDownBox.Items.Clear() dropDownBox.Items.Add(New System.Web.UI.WebControls.ListItem("- Select MapTips Layer -")) ' Loop through the available resources, adding the layer names of each to the DropDownBox For Each resourceItem As ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem In MapResourceManager1.ResourceItems ' If the resource item refers to a graphics resource, skip to the next If TypeOf resourceItem.Resource Is ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource Then Continue For End If ' Get the map functionality for the current resource Dim commonMapFunctionality As ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality = Map1.GetFunctionality(resourceItem.Name) ' Get the names and ids of the layers contained in the current resource Dim layerIDs() As String = Nothing Dim layerNames() As String = Nothing commonMapFunctionality.GetLayers(layerIDs, layerNames) ' Loop through the layer names and IDs adding each to the DropDownBox For i As Integer = 0 To layerNames.Length - 1 ' Create a string containing the current resource name and current layer ID, delimited by a colon Dim resourceAndLayerID As String = String.Format("{0}:{1}", resourceItem.Name, layerIDs(i)) ' Create a list item with the current layer name as the text and the resource name and layer ID ' as the value. This will allow the DropDownBox's ServerAction implementation easy access to the ' layer ID and name of the parent resource item. Dim listItem As New System.Web.UI.WebControls.ListItem(layerNames(i), resourceAndLayerID) ' Add the item to the DropDownBox dropDownBox.Items.Add(listItem) Next i Next resourceItem End If End Sub End Class