Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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:

 <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>

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);
share|improve this question
    
Please update the title to be more descriptive. –  Jon Bringhurst Jul 22 '10 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 Jul 23 '10 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. –  shawn deutch Jul 23 '10 at 16:38
add comment

1 Answer

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 ?

GOOOOOOOOD LUCK!

share|improve this answer
    
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/… –  shawn deutch Jul 26 '10 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); –  shawn deutch Jul 26 '10 at 14:14
    
Not sure if the RegisterStartupScript has a place in the solution to your problem. –  Dandy Jul 26 '10 at 14:41
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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