Common Partial Postback
Common_PartialPostback_VBNet\App_Code\CustomTool.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
Namespace CustomTools
  ' Centers the map control at the point specified by the passed-in argumetns
  Public Class CustomCenterTool
        Implements ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.IMapServerToolAction
    #Region "IMapServerToolAction Members"

    Private Sub ServerAction(ByVal toolEventArgs As ESRI.ArcGIS.ADF.Web.UI.WebControls.ToolEventArgs) Implements ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools.IMapServerToolAction.ServerAction
      ' Get a reference to the Web ADF Map control that was clicked
      Dim adfMap As ESRI.ArcGIS.ADF.Web.UI.WebControls.Map = CType(toolEventArgs.Control, ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)

      ' Cast the passed-in arguments to PointEventArgs for referencing the click point
      Dim pointEventArgs As ESRI.ArcGIS.ADF.Web.UI.WebControls.PointEventArgs = TryCast(toolEventArgs, ESRI.ArcGIS.ADF.Web.UI.WebControls.PointEventArgs)

      ' Center the map at the click point
      If Not adfMap Is Nothing AndAlso Not pointEventArgs Is Nothing Then
        adfMap.CenterAt(pointEventArgs.ScreenPoint)
      End If
    End Sub

    #End Region
  End Class

End Namespace