Common Simple UserControlTask


Purpose
This sample demonstrates how to create a custom ASP.NET User control as an Application Developer Framework (ADF) task. Traditional ADF Web tasks utilize and implement the ADF task framework within the context of a composite server control, which can be distributed to multiple users and sites. However, Visual Studio does not provide a visual interface for ASP.NET server control development, so the parent container and child components must be added and configured programmatically. This often requires detailed knowledge of custom server control development and lifecycle. ASP.NET user controls have a visual interface for defining control structure but offer limited extensibility options and are only designed for use within a specific Web application. However, this does not inhibit the ability of a User control to operate as a Web ADF task, it merely changes the underlying implementation.
 
This sample includes the following projects and folders:
  • UserControlTasks—Contains the Web control with intended visual UI for the task and will be plugged into TaskControl property exposed by UserControlTask web control. The webcontrol implements UserControlTaskPanel which is an abstract class that exposes methods for tapping into the task framework and executing ADF Web task logic. When the path to your usercontrol is set on a UserControlTask, the usercontrol task will bring up this control as its interface.
  • UserControlConfigurators: Contains a webcontrol that ca be used to configure the task when creating application using ArcGIS Server Manager. Once the task is added it can be configured as desired. For demonstration this configurator will change the default text and backcolor of the usercontroltask. For more information on Task integration and configuration with manager please refer to walkthrough UserControlTask control integration with Manager
  • Web application— Contains a web page with ADF controls : Scriptmanger, TaskManager and TaskResults. UserControlTask Web control, which extends ADF FloatingPanelTask to reference a User control via the TaskControl property has been also been added to TaskManager. Events triggered by controls in the User control call the Start method in a UserControlTask class, which wraps the User control. This simple call to Start starts task execution. Override the ExecuteTask method in the User control; it will be called after Start and can be used to process inputs and generate results.  

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 Developer Kit install location>\Samples\ServerNET\Common_SimpleUserControlTask.
  3. Open the folder of the language you're going to use—CSharp or VBNet—and copy the Common_SimpleUserControlTask _<language> folder to c:\inetpub\wwwroot. The <language> variable can be either CSharp or VBNet.
  4. Start Microsoft Visual Studio 2008 or 2010 and open the Common_SimpleUserControlTask _<language><vs_version> solution (for example, Common_SimpleUserControlTask _CSharp2008.sln) located in c:\inetpub\wwwroot\Common_SimpleUserControlTask _<language>. The <vs_version> references the Visual Studio version of the solution, 2008 or 2010.
  5. In Solution Explorer, navigate to the UserControlTasks folder, and open either User control in Design view. A visual interface for dragging-and-dropping and positioning controls is available.

At run time
  1. Start the Web application.
  2. In the User control, enter a value in the text box and click the Execute button. The value entered in the text box displays in the TaskResults control with default context menus.

Common_SimpleUserControlTask_CSharp\UserControlConfigurators\SimpleTaskWebConfig\SimpleTaskWebConfigurator.ascx Markup for web user control to allow task configuration via ArcGIS Server Manager
Common_SimpleUserControlTask_CSharp\UserControlConfigurators\SimpleTaskWebConfig\SimpleTaskWebConfigurator.ascx.cs Implementable code for user control task configurator.
Common_SimpleUserControlTask_CSharp\UserControlTasks\SimpleTask\SimpleTask.ascx Markup for a User control task.
Common_SimpleUserControlTask_CSharp\UserControlTasks\SimpleTask\SimpleTask.ascx.cs Implementation code for the User control task.
Common_SimpleUserControlTask_CSharp\Default.aspx Markup for the default web page containing usercontroltask web control.
Common_SimpleUserControlTask_CSharp\Default.aspx.cs Code behind for default.aspx
Download the C# files
Common_SimpleUserControlTask_VBNet\UserControlConfigurators\SimpleTaskWebConfig\SimpleTaskWebConfigurator.ascx Markup for web user control to allow task configuration via ArcGIS Server Manager
Common_SimpleUserControlTask_VBNET\UserControlConfigurators\SimpleTaskWebConfig\SimpleTaskWebConfigurator.ascx.vb Implementable code for user control task configurator.
Common_SimpleUserControlTask_VBNET\UserControlTasks\SimpleTask\SimpleTask.ascx Markup for a User control task.
Common_SimpleUserControlTask_VBNET\UserControlTasks\SimpleTask\SimpleTask.ascx.vb Implementation code for the User control task.
Common_SimpleUserControlTask_VBNET\Default.aspx Markup for the default web page containing usercontroltask web control.
Common_SimpleUserControlTask_VBNET\Default.aspx.vb Code behind for default.aspx
Download the VB.NET files

Download the files for all languages