ESRI.ArcGIS.ADF.Web.UI.WebControls
ServerAction Method
See Also  Example
ESRI.ArcGIS.ADF.Web.UI.WebControls.Tools Namespace > IMapServerToolAction Interface : ServerAction Method




args
Holds the results of the client-side interaction.
This is the method in which the server-side action of a tool is performed.

Syntax

Visual Basic (Declaration) 
Sub ServerAction( _
   ByVal args As ToolEventArgs _
) 
Visual Basic (Usage)Copy Code
Dim instance As IMapServerToolAction
Dim args As ToolEventArgs
 
instance.ServerAction(args)
C# 
void ServerAction( 
   ToolEventArgs args
)

Parameters

args
Holds the results of the client-side interaction.

Example

In this example, a user clicked on a point on the Map with a Tool, and the following server-side method is called. The method retrieves the screen point and converts it to map coordinates.
Visual BasicCopy Code
Public Class MyPointToolAction

    Implements IMapServerToolAction



    Sub ServerAction(ByVal args As ToolEventArgs) _

        Implements IMapServerToolAction.ServerAction



        Dim map As ESRI.ArcGIS.ADF.Web.UI.WebControls.Map = _

           CType(args.Control, ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)



        Dim pArgs As PointEventArgs = CType(args, PointEventArgs)

        Dim screenPt As System.Drawing.Point = pArgs.ScreenPoint



        Dim transParams As ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams = _

            map.GetTransformationParams(TransformationDirection.ToMap)

        Dim pnt As ESRI.ArcGIS.ADF.Web.Geometry.Point = _

            ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screenPt.X, screenPt.Y, transParams)



        ' Do something with the point...



    End Sub

End Class

C#Copy Code
public class MyPointToolAction: IMapServerToolAction 

{       

    void IMapServerToolAction.ServerAction(ToolEventArgs args) 

    { 

         

        ESRI.ArcGIS.ADF.Web.UI.WebControls.Map map = 

           (ESRI.ArcGIS.ADF.Web.UI.WebControls.Map)args.Control; 

  

        PointEventArgs pArgs = (PointEventArgs)args; 

        System.Drawing.Point screenPt = pArgs.ScreenPoint; 

  

        ESRI.ArcGIS.ADF.Web.Geometry.TransformationParams transParams = 

            map.GetTransformationParams(TransformationDirection.ToMap); 

        ESRI.ArcGIS.ADF.Web.Geometry.Point pnt = 

            ESRI.ArcGIS.ADF.Web.Geometry.Point.ToMapPoint(screenPt.X, screenPt.Y, transParams); 

                     

        // Do something with the point... 

         

    } 



    

Remarks

This method performs the action on the server for a Tool. A tool typically has a client-side action, where the user clicks on the Map to define geometry for the action. For example, an identify operation might require the user to click at a point on the map. The geometry is passed to the server within the ToolEventArgs argument of the ServerAction method.

ToolEventArgs is an abstract class. The actual object is a type that extends ToolEventArgs to contain a specific type of geometry. For example, if the client action of a Tool is Polygon, then the argument passed to ServerAction will be a PolygonEventArgs. The geometry may be retrieved from the properties of the argument object. Cast the argument to the appropriate type in order to retrieve the geometry. Note that the geometry will be in screen pixels. These locations may be converted to ADF geometry using methods such as Point.ToMapPoint or Envelope.ToMapEnvelope.

For another example of using this method, see the Common_AddCustomTool sample in the SDK Web Applications samples (also available at ArcGIS Resource Center:http).

See Also

© 2010 All Rights Reserved.