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 life cycle. ASP.NET User controls have a visual interface for defining control structure but offer limited extensibility options and are only 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 user interface (UI) for the task and will be plugged into the TaskControl property exposed by the UserControlTask Web control. The Web control 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 User control is set on a UserControlTask, the UserControlTask bring up this control as its interface.
  • Configurators—Contains a Web control that can be used to configure the task when creating an application using ArcGIS Server Manager. Once the task is added, it can be configured as necessary. For demonstration, this configurator changes the default text and backcolor of the UserControlTask. For more information on task integration and configuration with manager, see UserControl task Manager integration.
  • Web application—Contains a Web page with ScriptManager, TaskManager, and TaskResults ADF controls. 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 are going to use (that is, CSharp or VBNet) and copy the Common_SimpleUserControlTask _<language> folder to c:\inetpub\wwwroot. The <language> variable can be CSharp or VBNet.
  4. Start Visual Studio 2010 and open the Common_SimpleUserControlTask _<language><vs_version> solution (for example, Common_SimpleUserControlTask _CSharp2010.sln) located in c:\inetpub\wwwroot\Common_SimpleUserControlTask _<language>.
  5. In the 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, add a value in the text box and click the Execute button. The added value shows in the TaskResults control with default context menus.

SimpleUserControlTask_CSharp\Configurators\SimpleTaskWebConfig\TaskWebConfigurator.ascx Markup for a Web User control to allow task configuration via ArcGIS Server Manager.
SimpleUserControlTask_CSharp\Configurators\SimpleTaskWebConfig\TaskWebConfigurator.ascx.cs Implementation code for User control task configurator.
SimpleUserControlTask_CSharp\UserControlTasks\SimpleTask\SimpleTask.ascx Markup for a User control task.
SimpleUserControlTask_CSharp\UserControlTasks\SimpleTask\SimpleTask.ascx.cs Implementation code for the User control task.
SimpleUserControlTask_CSharp\Default.aspx Markup for the default Web page containing the UserControlTask Web control.
SimpleUserControlTask_CSharp\Default.aspx.cs Code behind for default.aspx.
Download the C# files
SimpleUserControlTask_VBNet\Configurators\SimpleTaskWebConfig\TaskWebConfigurator.ascx Markup for a Web user control to allow task configuration via ArcGIS Server Manager.
SimpleUserControlTask_VBNet\Configurators\SimpleTaskWebConfig\TaskWebConfigurator.ascx.vb Implementation code for User control task configurator.
SimpleUserControlTask_VBNET\UserControlTasks\SimpleTask\SimpleTask.ascx Markup for a User control task.
SimpleUserControlTask_VBNET\UserControlTasks\SimpleTask\SimpleTask.ascx.vb Implementation code for the User control task.
SimpleUserControlTask_VBNET\Default.aspx Markup for the default Web page containing the UserControlTask Web control.
SimpleUserControlTask_VBNET\Default.aspx.vb Code behind for default.aspx.
Download the VB.NET files

Download the files for all languages