Managing your web controls, Event handling, Error management – Pitney Bowes MapXtreme User Manual
Page 87: Event handling error management

Chapter 5: Web Applications, Controls, and Tools
Managing Your Web Controls
MapXtreme v7.1
87
Developer Guide
If your application requires multiple maps, they can exist in one or more workspaces, each with a
unique MapAlias property. To preload more than one workspace in the Web.config file, use a
semicolon between the full path of each workspace.
3. Make sure that MapAlias property of the MapControl is set. The default MapAlias for the
MapControl in the template is Map1. If this property is not set, MapXtreme will render the first
map from the session which may not be the map you expect.
To determine the MapAlias, open the .mws file in a text editor and look for the MapDefinition
element. The MapAlias is stored as an alias attribute.
You can also find the MapAlias from Workspace Manager. When you hover the mouse pointer
over the map node (top node in the layer list), the alias appears in a ToolTip.
4. Set the MapControlID property for all map tools, LayerControl, LegendControl and custom
controls (if any) to point to the appropriate MapControl.
Managing Your Web Controls
An important part to using Web controls is managing them effectively. This section explains how to
perform:
•
•
•
Event Handling
Map tool events are handled through client-side JavaScript commands that send a request to the
server. On the server-side a command class derived from MapBaseCommand does processing for
the tool.
In many command cases, the result of the server-side processing is sent back to the client. This is
an image in the case of the MapControl or XML in the case of the LayerControl. Then, only a portion
of the web page is updated with the command result via client-side JavaScript (for example, a new
map image is displayed after panning).
Error Management
Error handling in the Web controls can be handled in many ways, and it is very specific to the
application. Therefore, this section only explains one of the ways of handling errors. Since the
response expected by the client side is an image, we can catch the exception using a detailed
message, and send the response back with both an image and an error message. As a result, the
MapControl will now contain the error message.