Common_MapTips_CSharp\ShowOnlyOnClick.aspx.cs
// 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. // using System; using System.Configuration; using System.Data; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.HtmlControls; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; public partial class ShowOnlyOnClick : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string showMapTipsOnClickJavaScript = @" // Declare a function to call the setup method. The setup method is located in the // page markup. Note that we place the call in a timeout to ensure that the script // containing the function has been loaded prior to it being called. function invokeSetupFunction() {{ // Pass the client-side GraphicFeatureGroup to the setup method window.setTimeout(""setupMapTipsOnClick($find('{0}'));"", 0); }} // Wire the function to fire during the AJAX client-side load event Sys.Application.add_load(invokeSetupFunction);"; // Replace "{0}" with the MapTips GraphicsLayer's client-side ID showMapTipsOnClickJavaScript = string.Format(showMapTipsOnClickJavaScript, MapTips1.GraphicsLayerClientID); // Register the code as a startup script Page.ClientScript.RegisterStartupScript(this.GetType(), "showMapTipsOnClick", showMapTipsOnClickJavaScript, true); Map1.ResourceRefreshed += new ESRI.ArcGIS.ADF.Web.UI.WebControls.MapResourceRefreshedEventHandler(Map1_ResourceRefreshed); } void Map1_ResourceRefreshed(object sender, ESRI.ArcGIS.ADF.Web.UI.WebControls.ResourceRefreshedEventArgs args) { // Check whether the resource being refreshed is the MapTip's graphics layer if (args.MapResource.Name == "ESRI ADF Layer Map Tips") { // JavaScript needed to re-initialize the show on click functionality string reInitMapTips = string.Format("setupMapTipsOnClick($find('{0}'));", MapTips1.GraphicsLayerClientID); // Package the JavaScript in a callback result and add it to the Map's collection ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult reApplyHandlersCallbackResult = ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult.CreateJavaScript(reInitMapTips); Map1.CallbackResults.Add(reApplyHandlersCallbackResult); } } }