ADFTutorials_VBNet\ScriptableControls\MapCoordinateDisplay\MapCoordinateDisplay.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.Collections.Generic Imports System.ComponentModel Imports System.Text Imports System.Web Imports System.Web.UI Imports System.Web.UI.WebControls Namespace MapCoordinateDisplay <DefaultProperty("Text"), _ ToolboxData("<{0}:MapCoordinateDisplay runat=server></{0}:MapCoordinateDisplay>"), _ AjaxControlToolkit.ClientScriptResource("MapCoordinateDisplay.MapCoordinateDisplay", "MapCoordinateDisplay.js")> _ Public Class MapCoordinateDisplay Inherits ESRI.ArcGIS.ADF.Web.UI.WebControls.WebControl Private m_displayLabel As Label Public Property Text() As String Get Return TryCast(StateManager.GetProperty("text"), String) End Get Set(ByVal value As String) StateManager.SetProperty("text", value) End Set End Property ''' <summary>The ID of the Map control to associate with this control.</summary> Public Property Map() As String Get Return TryCast(StateManager.GetProperty("map"), String) End Get Set(ByVal value As String) StateManager.SetProperty("map", value) End Set End Property Protected Overrides Sub CreateChildControls() Controls.Clear() MyBase.CreateChildControls() m_displayLabel = New Label() m_displayLabel.ID = "DisplayLabel" m_displayLabel.Text = Text m_displayLabel.Font.Bold = True Controls.Add(m_displayLabel) End Sub Protected Overrides Sub OnPreRender(ByVal e As EventArgs) MyBase.OnPreRender(e) If (Not MyBase.IsAsync) Then Dim script As StringBuilder = New StringBuilder() script.Append("Sys.Application.add_init(function() {") script.Append("$create(MapCoordinateDisplay.MapCoordinateDisplay,") script.AppendFormat("{{""displayLabel"":$get('{0}')", m_displayLabel.ClientID) script.AppendFormat("}}, null, {{""map"":""{0}""}}, $get('{1}'));", Map, ClientID) script.AppendLine("});") ScriptManager.RegisterStartupScript(Me, GetType(MapCoordinateDisplay), Me.ClientID & "_startup", script.ToString(), True) End If End Sub End Class End Namespace