I am only using the map control and two toolbars on a custom webadf application.

One toolbar contains the standard map navigation controls.

The other toolbar is only one toolitem which references a class in app_code:

Here is the markup:

                <esri:Toolbar ID="tbSelectParcelToolBar" runat="server" Height="36px" Width="155px" BuddyControlType="Map" Group="tbSelectParcelToolBar_Group" ToolbarItemDefaultStyle-BackColor="White" ToolbarItemDefaultStyle-Font-Names="Verdana" ToolbarItemDisabledStyle-BackColor="White" ToolbarItemDisabledStyle-Font-Names="Verdana" ToolbarItemDisabledStyle-ForeColor="Gray" ToolbarItemHoverStyle-BackColor="White" ToolbarItemHoverStyle-Font-Bold="True" ToolbarItemHoverStyle-Font-Italic="False" ToolbarItemHoverStyle-Font-Names="Verdana" ToolbarItemSelectedStyle-BackColor="White" ToolbarItemSelectedStyle-Font-Bold="True" ToolbarItemSelectedStyle-Font-Names="Verdana" WebResourceLocation="/aspnet_client/ESRI/WebADF/" TextPosition="Right" CssClass="tbSelectParcelToolBar" ToolbarItemDefaultStyle-CssClass="tbSelectParcelToolBar" ToolbarItemDefaultStyle-Font-Overline="False" ToolbarItemHoverStyle-CssClass="tbSelectParcelToolBar" ToolbarItemSelectedStyle-CssClass="tbSelectParcelToolBar" ToolbarItemDefaultStyle-Font-Bold="True" Alignment="Left" ToolbarItemDefaultStyle-Font-Size="10pt" ToolbarItemDisabledStyle-Font-Size="10pt" ToolbarItemHoverStyle-Font-Size="10pt" ToolbarItemSelectedStyle-Font-Size="10pt">
                        <esri:Tool ClientAction="Point" DefaultImage="~/images/SelectParcel_ButtonDefault.gif" JavaScriptFile="" Name="SelectParcel" ServerActionAssembly="App_Code" ServerActionClass="SelectParcel" Text="Select Parcel"/>
                        <esri:BuddyControl Name="CCSDemoltionTrackerEditMap" />

After I use my tool once I want to set the current tool back to "MapPan"

The code below does select the Pan tool but on the client my select tool is still the cursor and the current active tool. What am I missing here??

           ESRI.ArcGIS.ADF.Web.UI.WebControls.Map adfMap = CCSDemoltionTrackerEditMap;

        string newCurrentTool = "MapPan";
        adfToolbar.CurrentTool = newCurrentTool;

        ESRI.ArcGIS.ADF.Web.UI.WebControls.ToolbarItem toolbarItem; 
        toolbarItem = adfToolbar.ToolbarItems.Find(adfToolbar.CurrentTool);

        ESRI.ArcGIS.ADF.Web.UI.WebControls.Tool currentTool;
        currentTool = toolbarItem as ESRI.ArcGIS.ADF.Web.UI.WebControls.Tool;

        // Set Map Current tool - server
        ESRI.ArcGIS.ADF.Web.UI.WebControls.MapToolItem mapToolItem;
        mapToolItem = adfMap.ToolItems.Find(adfToolbar.CurrentTool) as ESRI.ArcGIS.ADF.Web.UI.WebControls.MapToolItem;

        adfMap.CurrentToolItem = mapToolItem;

        // Set current tool on the client (sync toolbar and map controls in browser)

        string setActiveToolScript = string.Format(@"

// Set toolbar current tool - client

var toolbar = Toolbars['{0}'];

var currentToolField = $get(toolbar.currentToolField);

currentToolField.value = '{1}';



// Set map current tool - server

var clientAction = toolbar.items['{1}'].clientAction;

var clientFunction = clientAction + ""('{2}', '{1}', {3}, '{4}')"";    




        ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult cr;
        cr = ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult.CreateJavaScript(setActiveToolScript);
  • Please update the title to be more descriptive. Commented Jul 22, 2010 at 20:38
  • Did you spell the name of the map control correctly in the BuddyControls collection of your second toolbar? If the map isn't receiving the callback results collection then it won't update like you want. I think that will also trigger a Javascript error too.
    – mwalker
    Commented Jul 23, 2010 at 6:17
  • I am really looking to be able to deselect one tool on an ESRI toolbar control and select another tool on another ESRI toolbar and do this in code. Commented Jul 23, 2010 at 16:38

1 Answer 1


If by "does select the Pan tool but on the client my select tool is still the cursor and the current active tool" you mean it functions right but does not look right then I would assume your javascript side of that messy system is out of sync with the ASP.NET side. My best guess is that you forgot to send that callback result (CallbackResult cr) out the the client. You can use the ASP.NET AJAX script manager to send it out when you are done with everything. See: http://www.google.com/search?q=callbackresults+add+ScriptManager+RegisterDataItem&btnG=Search

http://support.esri.com/en/knowledgebase/techarticles/detail/35225 ?


  • Yup I am trying to work from the resources.arcgis.com/content/kbase?fa=articleShow&d=35225 ? bug example. I realized it will work after I force a reload of the page twice for some odd reason. I have not tried using the RegisterDataItem approach. I may try to work this example: blogs.esri.com/Dev/blogs/arcgisserver/archive/2007/04/02/… Commented Jul 26, 2010 at 14:13
  • I did try working with this construct: //adfMap.CallbackResults.Add(deactivateToolbarItemsCallbackResult); //ScriptManager.RegisterClientScriptBlock(Page, adfMap.CallbackResults.ToString(), true); //this.Page.ClientScript.RegisterStartupScript(GetType(), "SetMapPan", jsToolbarItemDeactivate, true); Commented Jul 26, 2010 at 14:14
  • Not sure if the RegisterStartupScript has a place in the solution to your problem.
    – Dandy
    Commented Jul 26, 2010 at 14:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.