Common_MapTips_VBNet\ShowOnlyOnClick.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.Configuration Imports System.Data Imports System.Web Imports System.Web.Security Imports System.Web.UI Imports System.Web.UI.HtmlControls Imports System.Web.UI.WebControls Imports System.Web.UI.WebControls.WebParts Partial Public Class ShowOnlyOnClick Inherits System.Web.UI.Page Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Dim showMapTipsOnClickJavaScript As String = "" & ControlChars.CrLf & " // Declare a function to call the setup method. The setup method is located in the" & ControlChars.CrLf & " // page markup. Note that we place the call in a timeout to ensure that the script " & ControlChars.CrLf & " // containing the function has been loaded prior to it being called." & ControlChars.CrLf & " function invokeSetupFunction() {{" & ControlChars.CrLf & " // Pass the client-side GraphicFeatureGroup to the setup method" & ControlChars.CrLf & " window.setTimeout(""setupMapTipsOnClick($find('{0}'));"", 0);" & ControlChars.CrLf & " }} " & ControlChars.CrLf & ControlChars.CrLf & " // Wire the function to fire during the AJAX client-side load event" & ControlChars.CrLf & " 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(Me.GetType(), "showMapTipsOnClick", showMapTipsOnClickJavaScript, True) AddHandler Map1.ResourceRefreshed, AddressOf Map1_ResourceRefreshed End Sub Private Sub Map1_ResourceRefreshed(ByVal sender As Object, ByVal args As ESRI.ArcGIS.ADF.Web.UI.WebControls.ResourceRefreshedEventArgs) ' Check whether the resource being refreshed is the MapTip's graphics layer If args.MapResource.Name = "ESRI ADF Layer Map Tips" Then ' JavaScript needed to re-initialize the show on click functionality Dim reInitMapTips As String = String.Format("setupMapTipsOnClick($find('{0}'));", MapTips1.GraphicsLayerClientID) ' Package the JavaScript in a callback result and add it to the Map's collection Dim reApplyHandlersCallbackResult As ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult = ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult.CreateJavaScript(reInitMapTips) Map1.CallbackResults.Add(reApplyHandlersCallbackResult) End If End Sub End Class