3

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);
PolyGeo
65.5k29 gold badges115 silver badges349 bronze badges
asked Jul 22, 2010 at 20:03
3
  • 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. 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

3

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!

Brad Koch
4856 silver badges24 bronze badges
answered Jul 26, 2010 at 4:48
3
  • 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. Commented Jul 26, 2010 at 14:41

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.