Replacing controls, State and event management, Specialized topics for web controls – Pitney Bowes MapXtreme User Manual

Page 100: Using web controls in frames, Replacing controls state and event management

Advertising
background image

Chapter 5: Web Applications, Controls, and Tools

Specialized Topics for Web Controls

MapXtreme v7.1

100

Developer Guide

Replacing Controls

Replacing controls can be done in various ways, either by deleting the older Web controls from the
form and dragging and dropping the new Web controls on the form, or by creating new Web forms,
dragging and dropping the new controls and then start adding functionality from the old forms to the
new forms. Make sure to set the appropriate MapAlias for the MapControl and set the appropriate
MapControlID for all dependent tools and the LayerControl.

State and Event Management

In most cases, the older method of state management is to restore state in Page_Load and save
state in Page_Unload. This code must be moved to the new class which derives from the
StateManager into the RestoreState and SaveState methods.

If your web application handles state manually, then you must implement the StateManager and put
this in the ASP.NET session. It is a best practice with MapXtreme to manually handle state so that
you are only restoring the information needed. See

Chapter 6: Understanding State Management

.

In the case where Server.Transfer or Response.Redirect is used in a web page, the session is no
longer new. You must put the StateManager in the ASP.NET session if it previously does not exist.

Specialized Topics for Web Controls

The following sections refer to special usage of MapXtreme Web controls:

Using Web Controls in Frames

Using the MapControl in Table Cells

Web Control Localization

Using Web Controls in Frames

The MapXtreme Web controls work in frames. For information on how to create frames, framesets,
and assign pages to frames see the Visual Studio documentation.

When using Web controls in frames, remember that a frame points to a web page and a frameset
contains one or more frames. Take the following scenario: A page with a MapControl and other
pages with tools or a LayerControl that depend upon the MapControl. All of the pages form a
frameset.

Given the above scenario, the following rules apply:

The MapControlID must be manually entered into the properties for the dependent controls. If
there is a MapControl on the same page as the dependent control with the same ID, the tools
and LayerControl will pick that one.

Since the frame pages render in a particular order, the MapXtreme session will not be a new
session for frames rendered after the first frame. To ensure the StateManager is in place,
implement the following code. Ensure there is a StateManager class registered regardless of
what page is loaded, The following code is executed before RestoreState is called.

Advertising