views:

171

answers:

1

In my default.aspx page, I have some ESRI tools (and some commands) in a toolbar, so something like this.

<ToolbarItems>
    <esri:Tool ClientAction="MapPoint('Map1','%toolbarItem%',false,'crosshair') DefaultImage="~/images/default_tool.gif" 
    EnablePostBack="True" JavaScriptFile="" Name="TestTool" SelectedImage="~/images/selected_tool.gif" DisabledImage="~/images/disabled_tool.gif"
    ServerActionAssembly="Test.Web.Mapping" ServerActionClass="Test.Web.Mapping.TestTool"
    Text="It's a tool!" ToolTip="Use it." />
</ToolbarItems>

Now, I have some code which is used to disable the tool, effectively changing it's image. The code basically loops over the toolbar to find the tool that needs to be disabled and does it's deed.

After the code runs, everything works beautifully. The proper tool has been disabled and the image has changed accordingly.

The problem is, if I select, say, the magnify tool, the image for the tool which I just disabled immediately changes back to the default image.

It seems like there must be some block of Javascript running somewhere that resets the state of all tools to there defaults as defined in the Default.aspx page. I'm having trouble finding it though. Any ideas?

EDIT: The code for disabling the button is C# code that is something like the following...

foreach (InteractiveImageToolbarItem toolbarTool in toolbar.ToolbarItems)
{
    // First check to see if the dictionary even contains the tool, if not we assume the tool is enabled for all themes, so enable it and
    // move to the next iteration.
    if (!enabledTools.Keys.Contains(toolbarTool.Name))
    {
        toolbarTool.Disabled = false;
        continue;
    }

    // So the tool is in the list, this loop checks to see if the tool is enabled for the current theme, meaning the theme is in the list
    // associated with the tool.
    foreach (string themeFromConfig in enabledTools[toolbarTool.Name])
    {
        if (currentTheme != themeFromConfig)
        {
            toolbarTool.Disabled = true;
        }
        else
        {
            toolbarTool.Disabled = false;
            break;
        }
    }
}

It can see what should be enabled by looking at config values. Once again I'll mention, this part works fine.

Update 9/3/09: Ok, so I think I know what the problem is. In the Web ADF the method that gets called, ToolbarMouseDown, has a call at the end of it...

Toolbars[toolbarName].refreshGroup();

If a tool is clicked in any toolbar that is part of the same group as my toolbar, the image will be reset. I'm not sure I get the logic behind it, it makes it impossible to disable tools or change there images and have it persist. Whatever...

Anyway, this is all on the Javascript side of things, is there any way that I can tell when that refreshGroup call has been made or something? What I think needs to happen is when the image is reset to being enabled I need to immediately set it back to being disabled.

A: 

When WebADF controls render to the page, they reference the ADF javascript libraries. It's quite possible that there is something in the default library that is overwriting your image settings.

I would suggest using Firebug to add a javascript breakpoint to the onclick function of one of your tools, and stepping through the WebADF javascript and seeing what is happening.

womp
I apparently don't know how to do that. Tool bar items use the ToolbarMouseDown javascript function. I can't seem to figure out how to debug into it though. I know what file it's located in, but it's not part of my solution. Firebug just shows the script as a minified block of javascript. I'm sure what you've suggested is what's happening, I just can't tell how to take a look at what exactly is going on in the code. Do you have any insights into debugging the web ADF?
Carter