Common Partial postback


Purpose
This sample demonstrates how to utilize ASP.NET Asynchronous JavaScript and XML (AJAX) partial postbacks with the Web Application Developer Framework (ADF) controls. The Web ADF controls can leverage the partial postback pattern if a ScriptManager control is in the page. In addition, custom asynchronous partial postback solutions can be developed to initiate changes in map display and update other non-Web ADF components on a page.
 
This sample provides the following examples:
  • SimplePartialPostback.aspx—Illustrates a simple partial postback initiated from a button in an UpdatePanel. A label in the UpdatePanel is changed upon button click and the new content is returned to the browser.
  • AJAXDemo.aspx—Demonstrates how to associate Web ADF controls with other Web controls via UpdatePanels, triggers, and events. Extent changes in the map modify the content in the list box. Selections in the list box and drop-down list change the extent of the map. Custom content in the response is handled by registering data items with the ScriptManager.
  • Two pages have the same look and feel but illustrate different techniques for handling Web ADF callback results when a non-Web ADF control initiates a partial postback or a Web ADF control initiates a partial postback and a non-Web ADF content in the page needs to be updated. The techniques involve using dynamic client script blocks (RegisterScriptBlockDemo.aspx) and data items (RegisterDataItemDemo.aspx). Both pages contain the following:
    • A custom tool in a toolbar to center the map on a user click. Regardless of the AJAX pattern being used (callback versus partial postback), 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 CallbackResults collection and processed by Web ADF client-side JavaScript.
    • An ASP.NET Button control to initiate a partial postback that centers and zooms in on a user-entered point. The Button control is registered with the ScriptManager as an asynchronous postback control. Callback results are handled by the Web ADF JavaScript libraries.
    • A custom ASP.NET Menu control with manually-added menu items that enables you to zoom to an extent. The Menu control is registered with the ScriptManager as an asynchronous postback control. Callback results are processed by the Web ADF JavaScript libraries.

How to use

If the sample has associated data, you will find that the sample's zip file includes a "data" folder alongside the language folders. However, you will need to update the sample to point to the location of the data once you have extracted all the files.

At 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>\DeveloperKit10.0\Samples\ServerNET. This folder contains the Common_PartialPostback with CSharp and VBNet folders.
  3. Open the folder of the language you're going to use—CSharp or VBNet—and copy the Common_PartialPostback_<language> folder to c:\inetpub\wwwroot. The <language> variable can 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, expand Default Web Site, right-click the Common_PartialPostback_<language> folder, and click Properties. The Properties dialog box opens.
  6. Click the Directory tab, click the Create button in the Application Settings section, then click OK to close the Properties dialog box.
  7. Start Microsoft Visual Studio (2008 or 2010) and open the solution for the version of Visual Studio you're using. The Visual Studio version is appended to the solution file name. For example, the Visual Studio 2008 solution file for the Common_PartialPostback_CSharp sample is Common_PartialPostback_CSharp2008.sln and is located in the c:\inetpub\wwwroot\Common_PartialPostback_CSharp folder.
  8. In Solution Explorer, right-click the page you want to view and select Set As Start Page.
  9. Open that page in Design view, open the properties window for the MapResourceManager control, and click the ellipsis next to the ResourceItems property. The ResourceItem Collection Editor dialog box opens.
  10. Add or change the MapResourceItem associated with a map service (ArcGIS Server, ArcIMS, ArcWeb, and so forth). In some of the sample code, it is assumed that the resource is in a geographic coordinate system.
  11. If necessary, set the run time identity of the Web application by following one of the next two steps. If not necessary, proceed to step 14.
  12. At design time, the identity of the user running Visual Studio is used to connect to an ArcGIS Server local data source. At run time, that identity is established by the Web application. Only one identity can be used to define access to the 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 that will be used to access ArcGIS Server local resources at run time. This information is added to the web.config file in a standard ASP.NET identity tag. If the Encrypt identity in web.config check box is checked, the identity tag will be encrypted; otherwise, the username and password are stored as clear text.
  13. Open the web.config file, add an <identity> element in <system.web>, set the impersonate attribute to true, and add a username and password attribute and set them to a valid user account. If you're working with ArcGIS Server local data sources, ensure the account has access to the geographic information system (GIS) server resources referenced in the Map control.
  14. Save the project.
  15. Click the Debug drop-down menu and click Start Debugging.

At run time
  1. Browse to the viewer uniform resource locator (URL) (for example, http://localhost/Common_PartialPostback_CSharp).
  2. In the toolbar above the map, click the Zoom In tool, and zoom in to an area of the map. The Hypertext Markup Language (HTML) text on the edge of the Map control updates with the extent boundaries of the map. This information is appended to the callback for the Map control on an extent change. The Web ADF JavaScript libraries processes the custom CallbackResult objects and updates the appropriate content.
  3. In the toolbar above the map, click the CenterAt tool, and click an area of the map. The map redraws centered on the location clicked. The custom tool code shows 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 includes code to create custom CallbackResult objects to modify other content on the page. This is provided as an example of how to do this in a custom tool.
  4. Below the map, enter an x and y coordinate in the text boxes provided, and 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 code file (for example, Default.aspx.cs) processes the request and applies changes to the map. The map is refreshed on the client without requiring a full postback.
  5. In the custom menu in 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 coordinate system. You can change the code in the page code file to modify this behavior.

Common_PartialPostback_CSharp\SimplePartialPostback.aspx ASP.NET button and label in an UpdatePanel.
Common_PartialPostback_CSharp\SimplePartialPostback.aspx.cs Code behind the user interface.
Common_PartialPostback_CSharp\AJAXDemo.aspx Web ADF controls with list box and drop-down list.
Common_PartialPostback_CSharp\AJAXDemo.aspx.cs Code behind the user interface.
Common_PartialPostback_CSharp\RegisterScriptBlockDemo.aspx Web ADF controls and non-Web ADF controls interact using script blocks.
Common_PartialPostback_CSharp\RegisterScriptBlockDemo.aspx.cs Code behind the user interface.
Common_PartialPostback_CSharp\RegisterDataItemDemo.aspx Web ADF controls and non-Web ADF controls interact using data items.
Common_PartialPostback_CSharp\RegisterDataItemDemo.aspx.cs Code behind the user interface.
Common_PartialPostback_CSharp\App_Code\CustomTool.cs Contains implementation of custom tool.
Download the C# files
Common_PartialPostback_VBNet\SimplePartialPostback.aspx ASP.NET button and label in an UpdatePanel.
Common_PartialPostback_VBNet\SimplePartialPostback.aspx.vb Code behind the user interface.
Common_PartialPostback_VBNet\AJAXDemo.aspx Web ADF controls with list box and drop-down list.
Common_PartialPostback_VBNet\AJAXDemo.aspx.vb Code behind the user interface.
Common_PartialPostback_VBNet\RegisterScriptBlockDemo.aspx Web ADF controls and non-Web ADF controls interact using script blocks.
Common_PartialPostback_VBNet\RegisterScriptBlockDemo.aspx.vb Code behind the user interface.
Common_PartialPostback_VBNet\RegisterDataItemDemo.aspx Web ADF controls and non-Web ADF controls interact using data items.
Common_PartialPostback_VBNet\RegisterDataItemDemo.aspx.vb Code behind the user interface.
Common_PartialPostback_VBNet\App_Code\CustomTool.vb Contains implementation of custom tool.
Download the VB.NET files

Download the files for all languages