Common Callback



Description:

This sample illustrates how to utilize asynchronous callbacks with the Web ADF controls. The Web ADF provides event handling and standard interfaces server-side controls, such as a Map and Toolbar, as well as a complete set of JavaScript libraries to initiate and process callbacks on the client. The Web ADF are already callback enabled by default. However, custom asynchronous callback solutions can be developed to initiate changes in map display and update other non-Web ADF components on a page. The sample provides the following examples:

  • A custom tool in a toolbar to center the map on a user click. Custom CallbackResult objects are created to change the extent labels on all the edges of the map. The CallbackResult objects are added to the map control's CallbackResults collection and processed by Web ADF client-side JavaScript.
  • A custom HTML client-side button to initiate a callback which centers and zooms in on a user entered point. The Page implements the ICallbackEventHandler interface to handle the callback request (RaiseCallbackEvent()) and send the callback response (GetCallbackResult()). The callback response is handled by the Web ADF JavaScript libraries.
  • A custom ASP.NET Menu control with a couple manually added menu items that enable the user to zoom to an extent. The Page handles the callback request and response for the zoom to extent items.
  • Products:
    Server: C#, VB.NET

    Platforms: Windows

    Minimum ArcGIS Release: 9.2

    How to use:
    1. Design Time:
      1. Verify that the Web ADF for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
      2. In Windows Explorer, navigate to <ArcGIS install location>\DeveloperKit\SamplesNet\Server\Web_Applications and unzip Common_CallbackCSharp.zip or Common_CallbackVBNet.zip to a location of your choice. You should see either a CSharp or VBNet folder appear where you unzipped the files.
      3. In Windows Explorer, open the directory referencing the language of your choice: CSharp or VBNet. Copy the folder, Common_Callback_<language>, to c:\inetpub\wwwroot. The <language> variable may be either CSharp or VBNet.
      4. Open the IIS Manager from Control Panel > Administrative Tools > Internet Information Services (IIS) Manager or Internet Information Services
      5. In the console tree view on the left, navigate to Local Computer > Web Sites > Default Web Site.
      6. Expand Default Web Site then right-click the Common_Callback_<language> folder and click Properties.
      7. On the Directory tab, click the Create button in the Application Settings section of this panel. Click OK to dismiss the Properties dialog.
      8. Launch Microsoft Visual Studio 2005 and open the Common_Callback_<language> solution (for example, Common_Callback_CSharp.sln) located in c:\inetpub\wwwroot\Common_Callback_<language>.
      9. In the Solution Explorer, right-click Default.aspx and select 'Set As Start Page'.
      10. Open the Default.aspx page in design view. Open the properties window for the MapResourceManager control. Click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog should display.
      11. Add or change the MapResourceItem associated with a map service (ArcGIS Server, ArcIMS, ArcWeb, etc.). Some of the sample code assumes that the resource is in a geographic coordinate system.
      12. If necessary, set the runtime identity of the Web application:
        1. At design-time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At runtime, that identity is established by the Web application. Only one identity can be used to define access to all ArcGIS Server local data sources in a single Web application. This identity can be explicitly defined when building the Web ADF application in Visual Studio by right-clicking the Web project in Solution Explorer, and selecting the Add ArcGIS Identity option. Enter the identity credentials which will be used to access ArcGIS Server local resources at runtime. This information will be added to the web.config file within a standard ASP.NET identity tag. If the "Encrypt identity in web.config" checkbox is checked, the identity tag will be encrypted, otherwise the username and password will be stored as clear text.
          -or-
        2. Open the web.config file and add an <identity> element within <system.web>. Set the impersonate attribute to "true". Add a userName and password attribute and set them to a valid user account. If working with ArcGIS Server Local data sources, make sure the account has access to the GIS Server resources referenced in the Map control.
      13. Save the project.
      14. Click the "Debug" drop-down menu and choose "Start".
    2. Run Time:
      1. Browse to viewer's URL (for example, http://localhost/Common_Callback_CSharp).
      2. In the toolbar above the map, click the "Zoom In" tool. Zoom into an area of the map.
      3. Note that the HTML text on the edges of the map control update with the extent boundaries of the map. This information was appended to the callback for the Map control upon an extent change. The Web ADF JavaScript libraries processed the custom CallbackResult objects and updated the appropriate content.
      4. In the toolbar above the map, click the "CenterAt Tool".
      5. Click on an area of the map. The map should redraw centered on the location clicked. Note in the custom tool code that the map control was not explicitly refreshed. If the content of the map does not change and the scale remains the same, the map does not need to call Refresh(). The custom tool also includeds some code to create custom CallbackResult objects to modify other content on the page. This is merely provided as an example of how to do this in a custom tool.
      6. Below the map, enter an x and y coordinate in the text boxes provided. Click the "Zoom To Point" button to zoom to the coordinate provided. This initiates a custom callback to the Web application. A string message containing the type of action and the coordinate values is sent to the Web application via the ZoomToPointClient() JavaScript function in the Default.aspx file. The ZoomToPointServer() method in the page codefile (e.g. Default.aspx.cs) processes the request and applies changes to the map. The map is refreshed on the client without requiring a full postback.
      7. In the custom Menu to the upper right of the Map, select the option to zoom to a defined location: California or New York. Both assume the map is in a geographic coordiate system. You can change the code in the page codefile to modify this behaviour.

    Download the C# files
    Default.aspx User interface for the Web application
    Common_Callback_CSharp/Default.aspx.cs The code behind the user interface
    Common_Callback_CSharp/App_Code/CustomTool.cs Class library containing implementation of custom tool.
    Download the VB.NET files
    Default.aspx User interface for the Web application
    Common_Callback_VBNet/Default.aspx.vb The code behind the user interface
    Common_Callback_VBNet/App_Code/CustomTool.vb Class library containing implementation of custom tool.

    Download the files for all languages