sdeutch

set toolbar item to none

Discussion created by sdeutch on Jul 22, 2010
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:
[HTML]     <div>
                 <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">
                        <ToolbarItems>
                            <esri:Tool ClientAction="Point" DefaultImage="~/images/SelectParcel_ButtonDefault.gif" JavaScriptFile="" Name="SelectParcel" ServerActionAssembly="App_Code" ServerActionClass="SelectParcel" Text="Select Parcel"/>
                        </ToolbarItems>
                        <BuddyControls>
                            <esri:BuddyControl Name="CCSDemoltionTrackerEditMap" />
                        </BuddyControls>
                    </esri:Toolbar>[/HTML]


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.Focus();
            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}';

    toolbar.selectTool();

    toolbar.refreshGroup();



    // Set map current tool - server

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

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

    eval(clientFunction);

    ",

                 adfToolbar.ClientID,
                 currentTool.Name,
                 adfMap.ClientID,
                 currentTool.ShowLoading.ToString().ToLower(),
                 currentTool.Cursor);

            ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult cr;
            cr = ESRI.ArcGIS.ADF.Web.UI.WebControls.CallbackResult.CreateJavaScript(setActiveToolScript);

Outcomes