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
- Verify that the Web Application Developer Framework (ADF) for the .NET Framework is installed and functioning properly. For information on installing and configuring the Web ADF, consult the installation guide.
- In Windows Explorer, navigate to <ArcGIS Developer Kit install location>\Samples\ServerNET\Common_CustomControls.
- Start Microsoft Visual Studio 2008 or 2010 and open the Common_CustomControls_<language><vs_version> solution (for example, Common_CustomControls_CSharp2008.sln) located in <unzipped location\Common_CustomControls_<language>. The <vs_version> references the Visual Studio version of the solution, either 2008 or 2010.
- In Solution Explorer, right-click the CustomControlsWebSite file system Web site and select Set as StartUp Project.
- Right-click the .aspx page that you're interested in and select Set As Start Page.
- Add the ADFCompositeControl and ADFWebPart projects as references to the CustomControlsWebSite if necessary.
- Open AddWebPartOnClick.aspx.cs and set the appropriate properties for MapWebPart and MapGridViewWebPart as follows: Define the data source type, location, and resource (map service) name for MapWebPart. The custom MapIdentify code and tool in MapWebPart will execute successfully but will not generate results. They are provided for instruction only. Add functionality to the tool if desired. Default properties are set in the constructor for MapWebPart and MapGridViewWebPart and use sample data provided by serverapps.esri.com and ArcGIS Online. To use the default properties, proceed to step 10. To change the properties of MapWebPart, proceed to step 8. To change the properties of MapGridViewWebPart, proceed to step 9.
- Define the data source type, location, and resource (map service) name. The custom MapIdentify code and tool in MapWebPart will execute successfully but will not generate results. They are provided for instruction only. Add functionality to the tool if desired.
- Define the data source type, location, and resource name for an ArcGIS Server non-cached map service. Ensure the map service contains a point feature layer to be used to display graphics in the map and attributes in the GridView. Set the DataLayerName property to the name of the point feature layer. To filter and alias the field names in the point feature layer, which will be listed in the GridView, define a fields collection and set the DisplayFields property. MapGridViewWebPart contains a map resource that references the ArcGIS Online StreetMap service as a base layer. The non-cached map service is projected on the fly to the projection of the StreetMap service. A Geometry service is also used to project the default extent of the non-cached map service into the projection of the StreetMap service, and is then used to set the extent of the Map control. Set the GeometryServiceUrl property to an available ArcGIS Server Geometry service.
- Open DesignComposite.aspx and set the appropriate properties on the MapToolTocControl in the markup. Define the data source type, location, and resource (map service) name. The custom MapIdentify code and tool in the MapToolTocControl will execute successfully but will not generate results. They are provided for instruction only. Add functionality to the tool if desired.
- Open WebUserControl.ascx in Design view and add a map resource. The code behind the User control contains a block of code to set buddy properties at the initialization phase of the control.
- In Windows Explorer, navigate to the App_Data\Personalization_Data folder in CustomControlsWebSite. Open the properties on the folder and provide read and write access to the user account under which the Web application will be running. If running as a file system Web site, integrated authentication is used by default.
At run time
- Start the Web application. Since it's a file system Web site, an ASP.NET Development server will start or an existing server instance will be used. Access to the site is limited to the local machine.
- In AddWebPartOnClick.aspx, click the Add MapWebPart or MapGridViewWebPart button. The respective Web Part control is added to the page. Multiple controls can be added in the same session. The MapWebPart control provides an interactive Map, Toolbar, and Toc. The MapGridViewWebPart control provides an interactive Map, GridView, and point graphic features in the Map (MapTips). The GridView contains attributes for the point features displayed in the Map. On hover of a data row, the respective point graphic feature in the map is highlighted. On click of a data row, the Map zooms to the respective graphic feature. Only graphic features in the Map extent are listed in the GridView. Click the Remove Web Parts button to remove all parts from the page. A text file containing encrypted data is generated in the App_Data\Personalization_Data folder. The text is used to store the authenticated user's personalized information.
- Optionally, interact with the Map, TOC, and Toolbar in the custom composite control on the DesignComposite.aspx page. This page illustrates that the Web ADF controls function as expected when contained in a composite control.
- Optionally, interact with the Map, TOC, and Toolbar in the custom Web user control on the DesignTimeUserControl.aspx page. This page illustrates that the Web ADF controls function as expected in a user control.
Additional information
ADFCompositeControl
The ADFCompositeControl project contains a custom composite server control. The server control contains Web ADF controls—Map, MapResourceManager, Toolbar, and Toc—that are created and configured during the lifecycle of the control and the page in which it resides. This control provides a basic pattern for utilizing Web ADF controls in a custom server control.
ADFWebPart
The ADFWebPart project contains custom composite server controls as ASP.NET Web Parts. ASP.NET Web Parts can be deployed with Microsoft Office SharePoint Server and personalized by end users. One Web Part—MapGridViewWebPart—contains a Web ADF Map and an ASP.NET GridView in an UpdatePanel and requires that a ScriptManager be present on the page. On initial load, the map shows a set of customers in downtown San Francisco. The GridView shows only those customers in the current map extent. On hover over a row in the GridView, the respective customer is highlighted in the map. On click of a row in the GridView, the map re-centers on the customer (graphic point) associated with the clicked row. All interaction rows in the GridView are managed on the client using the Web ADF JavaScript Library.
The other Web Part—MapWebPart—provides a simple ASP.NET Web Part example with a Map, MapResourceManager, Toolbar, and Toc. The default personalization provider for ASP.NET is SQL Express. If you do not have SQL Express installed, a personalization store is not created (on initial execution of the application), and an error is returned when attempting to add the custom Web Part to the page at run time. To alleviate this requirement, a custom personalization provider that uses text files has been added (TextFilePersonalizationProvider) to the demo Web site. The code, markup, and discussion for this technique is provided in the Web Parts Personalization Providers article.
The other Web Part—MapWebPart—provides a simple ASP.NET Web Part example with a Map, MapResourceManager, Toolbar, and Toc. The default personalization provider for ASP.NET is SQL Express. If you do not have SQL Express installed, a personalization store is not created (on initial execution of the application), and an error is returned when attempting to add the custom Web Part to the page at run time. To alleviate this requirement, a custom personalization provider that uses text files has been added (TextFilePersonalizationProvider) to the demo Web site. The code, markup, and discussion for this technique is provided in the Web Parts Personalization Providers article.
To deploy these Web Parts in SharePoint, use the ADF_AJAX_SharePoint_deployment_ReadMe.doc Word document (packaged with the sample) as a guide. A SharePoint 2007 server may not have session state enabled, which is necessary for Web ADF controls to function. If not enabled, SharePoint returns an uninformative error when attempting to add a custom Web Part that contains ADF controls to the SharePoint server. See step 5 in the Word document for more information.
CustomControlsWebSite
The CustomControlsWebSite Web site contains pages that demonstrate the use of the composite server control and Web Part controls. AddWebPartOnClick.aspx illustrates how to add and remove Web Parts at run time. This page can be used to test the run time use of a Web Part in SharePoint. DesignComposite.aspx illustrates how a custom composite server control can be added and configured at design time. This Web site also contains a custom Web user control (WebUserControl). The user control contains a Map, MapResourceManager, Toolbar, and Toc. The code behind the user control configures the buddy relationships that need to be established when the user control is initialized. DesignTimeUserControl.aspx illustrates how the custom user control is used in a page at design time.
CustomControlsWebSite is a file system Web site because integrated authentication is used by the ASP.NET development server to determine an authenticated user. The text file-based personalization provider requires an authenticated user to function. By default, IIS Web applications are configured with anonymous access enabled, so no authenticated user is provided. To use with IIS, disable anonymous access to the Web application.
CustomControlsWebSite is a file system Web site because integrated authentication is used by the ASP.NET development server to determine an authenticated user. The text file-based personalization provider requires an authenticated user to function. By default, IIS Web applications are configured with anonymous access enabled, so no authenticated user is provided. To use with IIS, disable anonymous access to the Web application.
Common_CustomControls_CSharp\ADFCompositeControl\Properties\AssemblyInfo.cs | Assembly information for ADFCompositeControl. |
Common_CustomControls_CSharp\ADFCompositeControl\MapToolTocControl.cs | ADFCompositeControl implementation code. Contains a MapResourceManager, Map, Toolbar, and Toc. |
Common_CustomControls_CSharp\ADFCompositeControl\MapIdentify.cs | Custom identify tool for ADFCompositeControl. |
Common_CustomControls_CSharp\ADFWebPart\Properties\AssemblyInfo.cs | Assembly information for ADFWebPart. |
Common_CustomControls_CSharp\ADFWebPart\AJAXSharePointWebPart.cs | Abstract class that provides code to workaround ASP.NET AJAX partial postback problems in SharePoint. |
Common_CustomControls_CSharp\ADFWebPart\MapGridViewWebPart.cs | Implementation code for a Web Part that requires a ScriptManager and contains a GridView in an UpdatePanel, a Map, and a MapResourceManager. Contains implementation code for interaction between tabular results in the GridView and graphics in the map. |
Common_CustomControls_CSharp\ADFWebPart\MapGridViewWebPartDesigner.cs | Implementation for rendering control at design time. |
Common_CustomControls_CSharp\ADFWebPart\MapWebPart.cs | Implementation code for a Web Part that contains a Map, MapResourceManager, Toolbar, and Toc. |
Common_CustomControls_CSharp\ADFWebPart\MapIdentify.cs | Implementation code for a custom identify tool in MapWebPart. |
Common_CustomControls_CSharp\ADFWebPart\Utility.cs | Utility classes for the Web Part controls. |
Common_CustomControls_CSharp\CustomControlsWebSite\AddWebPartOnClick.aspx | Contains buttons to add Web Part controls and remove all parts from the page at run time. |
Common_CustomControls_CSharp\CustomControlsWebSite\AddWebPartOnClick.aspx.cs | Code behind. Implementation code to add the ADFWebPart controls to the page. |
Common_CustomControls_CSharp\CustomControlsWebSite\DesignComposite.aspx | Contains ADFCompositeControl at design time. |
Common_CustomControls_CSharp\CustomControlsWebSite\DesignComposite.aspx.cs | Code behind. |
Common_CustomControls_CSharp\CustomControlsWebSite\DesignTimeUserControl.aspx | Contains the custom WebUserControl at design time. |
Common_CustomControls_CSharp\CustomControlsWebSite\DesignTimeUserControl.aspx.cs | Code behind. |
Common_CustomControls_CSharp\CustomControlsWebSite\WebUserControl.ascx | Custom Web user control contains a Map, MapResourceManager, Toolbar, and Toc. |
Common_CustomControls_CSharp\CustomControlsWebSite\WebUserControl.ascx.cs | Code behind the user control. Used to wire up buddy relationships. |
Common_CustomControls_CSharp\CustomControlsWebSite\App_Code\TextFilePersonalizationProvider.cs | Custom personalization provider enables the application to store personal information for authenticated users in a text file (App_Data\Personalization_Data). Personalization is required for the Web Part demos to function. |
Common_CustomControls_VBNet\ADFCompositeControl\Properties\AssemblyInfo.vb | Assembly information for ADFCompositeControl. |
Common_CustomControls_VBNet\ADFCompositeControl\MapToolTocControl.vb | ADFCompositeControl implementation code. Contains a MapResourceManager, Map, Toolbar, and Toc. |
Common_CustomControls_VBNet\ADFCompositeControl\MapIdentify.vb | Custom identify tool for ADFCompositeControl. |
Common_CustomControls_VBNet\ADFWebPart\Properties\AssemblyInfo.vb | Assembly information for ADFWebPart. |
Common_CustomControls_VBNet\ADFWebPart\AJAXSharePointWebPart.vb | Abstract class that provides code to workaround ASP.NET AJAX partial postback problems in SharePoint. |
Common_CustomControls_VBNet\ADFWebPart\MapGridViewWebPart.vb | Implementation code for Web Part that requires a ScriptManager and contains a GridView in an UpdatePanel, a Map, and a MapResourceManager. Contains implementation code for interaction between tabular results in the GridView and graphics in the map. |
Common_CustomControls_VBNet\ADFWebPart\MapGridViewWebPartDesigner.vb | Implementation for rendering control at design time. |
Common_CustomControls_VBNet\ADFWebPart\MapWebPart.vb | Implementation code for Web Part that contains a Map and MapResourceManager, Toolbar, and Toc. |
Common_CustomControls_VBNet\ADFWebPart\MapIdentify.vb | Implementation code for a custom identify tool in MapWebPart. |
Common_CustomControls_VBNet\ADFWebPart\Utility.vb | Utility classes for the Web Part controls. |
Common_CustomControls_VBNet\CustomControlsWebSite\AddWebPartOnClick.aspx | Contains buttons to add Web Part controls and remove all parts from the page at run time. |
Common_CustomControls_VBNet\CustomControlsWebSite\AddWebPartOnClick.aspx.vb | Code behind. Implementation code to add the ADFWebPart controls to the page. |
Common_CustomControls_VBNet\CustomControlsWebSite\DesignComposite.aspx | Contains ADFCompositeControl at design time. |
Common_CustomControls_VBNet\CustomControlsWebSite\DesignComposite.aspx.vb | Code behind. |
Common_CustomControls_VBNet\CustomControlsWebSite\DesignTimeUserControl.aspx | Contains the custom WebUserControl at design time. |
Common_CustomControls_VBNet\CustomControlsWebSite\DesignTimeUserControl.aspx.vb | Code behind. |
Common_CustomControls_VBNet\CustomControlsWebSite\WebUserControl.ascx | Custom Web user control contains a Map, MapResourceManager, Toolbar, and Toc. |
Common_CustomControls_VBNet\CustomControlsWebSite\WebUserControl.ascx.vb | Code behind the user control. Used to wire up buddy relationships. |
Common_CustomControls_VBNet\CustomControlsWebSite\App_Code\TextFilePersonalizationProvider.vb | Custom personalization provider enables the application to store personal information for authenticated users in a text file (App_Data\Personalization_Data). Personalization is required for the Web Part demos to function. |
Download the files for all languages