Common_MapTips_CSharp\SetMapTipsLayer.aspx.cs
// Copyright 2010 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. // public partial class _SetMapTipsLayer : System.Web.UI.Page { protected void Page_Load(object sender, System.EventArgs e) { if (!Page.IsPostBack) { // Retrieve the Web ADF DropDownBox that we wish to populate with layer names ESRI.ArcGIS.ADF.Web.UI.WebControls.DropDownBox dropDownBox = Toolbar1.ToolbarItems.Find("DropDownBox0") as 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 foreach (ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceItem resourceItem in MapResourceManager1.ResourceItems) { // If the resource item refers to a graphics resource, skip to the next if (resourceItem.Resource is ESRI.ArcGIS.ADF.Web.DataSources.Graphics.MapResource) continue; // Get the map functionality for the current resource ESRI.ArcGIS.ADF.Web.DataSources.IMapFunctionality commonMapFunctionality = Map1.GetFunctionality(resourceItem.Name); // Get the names and ids of the layers contained in the current resource string[] layerIDs = null; string[] layerNames = null; commonMapFunctionality.GetLayers(out layerIDs, out layerNames); // Loop through the layer names and IDs adding each to the DropDownBox for (int i = 0; i < layerNames.Length; i++) { // Create a string containing the current resource name and current layer ID, delimited by a colon string resourceAndLayerID = 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. System.Web.UI.WebControls.ListItem listItem = new System.Web.UI.WebControls.ListItem(layerNames[i], resourceAndLayerID); // Add the item to the DropDownBox dropDownBox.Items.Add(listItem); } } } } }