Common_CustomJavaScript_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 ' Shows how to retrieve arguments from callbacks and postbacks Public Class CustomArgumentsTool 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 Dim nameValueCollectionInsideArg As System.Collections.Specialized.NameValueCollection = Nothing ' Check whether the page request was issued using a callback or a postback. A callback is used if no ' ScriptManager is on the page containing the tool. Otherwise, a partial postback is used. If toolEventArgs.Control.Page.IsCallback Then ' Get the callback arguments from the __CALLBACKPARAM argument of the page request parameters Dim callbackArguments As String = toolEventArgs.Control.Page.Request.Params("__CALLBACKPARAM") nameValueCollectionInsideArg = ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackUtility.ParseStringIntoNameValueCollection(callbackArguments) ' Get the value of the DropDownList1 server control, which has been manually added to the tool's ' arguments via JavaScript in AddArgumentsToTool.aspx Dim dropDownListValue As String = nameValueCollectionInsideArg("DropDownList1") ' Get the value of the custom argument created via JavaScript in AddArgumentsToTool.aspx Dim inlineValue As String = nameValueCollectionInsideArg("inlineArgument") Else ' Get the value of the DropDownList1 server control, which is automatically included in postbacks ' (partial postbacks included) due to its being a server control Dim dropDownListValue As String = toolEventArgs.Control.Page.Request.Params("DropDownList1") ' Get the postback event arguments from the __EVENTARGUMENT argument of the page request parameters Dim postbackEventArguments As String = toolEventArgs.Control.Page.Request.Params("__EVENTARGUMENT") nameValueCollectionInsideArg = ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackUtility.ParseStringIntoNameValueCollection(postbackEventArguments) ' Get the value of the custom argument created via JavaScript in AddArgumentsToTool.aspx Dim inlineValue As String = nameValueCollectionInsideArg("inlineArgument") End If End Sub #End Region End Class End Namespace