Common Simple UserControlTask
SimpleUserControlTask_CSharp\UserControlTasks\SimpleTask\SimpleTask.ascx.cs
// Copyright 2011 ESRI
// 
// All rights reserved under the copyright laws of the United States
// and applicable international laws, treaties, and conventions.
// 
// You may freely redistribute and use this sample code, with or
// without modification, provided you include the original copyright
// notice and use restrictions.
// 
// See the use restrictions.
// 

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using ESRI.ArcGIS.ADF.Web.UI.WebControls;

//Derive from UserControlTaskPanel
public partial class SimpleTask : UserControlTaskPanel
{
    protected override void OnLoad(EventArgs e)
    //protected void Page_Load(object sender, System.EventArgs eventArgs)
    {
        #region Populate UI from task's configuration settings
        base.OnLoad(e);
        if (ScriptManager.GetCurrent(Page) != null ) 
        {
            System.Web.UI.ScriptManager scriptManager = System.Web.UI.ScriptManager.GetCurrent(this.Page);

            // Register the ASP.NET Button so it triggers a partial postback when clicked.  Note that this
            // does not need to be done for the Web ADF Callback Button.  This is because all Web ADF
            // controls are AJAX-enabled, so asynchronous functionality has been wired-up for the callback 
            // button automatically.
            scriptManager.RegisterAsyncPostBackControl(AspButton);

            if (!ScriptManager.GetCurrent(Page).IsInAsyncPostBack)
            {
                if (this.UserControlTask != null)
                {
                    if (!string.IsNullOrEmpty(this.UserControlTask.Configuration))
                        FromJsonstring(this.UserControlTask.Configuration);
                }
            }
        }
        #endregion
    }

    //Read of the configuration by parsing JSON string
    public void FromJsonstring(string json)
    {
        if (string.IsNullOrEmpty(json))
            return;

        ESRI.ArcGIS.ADF.XmlHelper xmlhelper = new ESRI.ArcGIS.ADF.XmlHelper();
        string decoded = xmlhelper.Decode(json);

        System.Web.Script.Serialization.JavaScriptSerializer jss = new System.Web.Script.Serialization.JavaScriptSerializer();
        System.Collections.Generic.IDictionary<string, object> deserilizedjson = jss.DeserializeObject(decoded) as System.Collections.Generic.IDictionary<string, object>;
        //set the textbox value by reading the json string from configuration
        if (deserilizedjson.ContainsKey("textboxvalue"))
            TextBox1.Text = deserilizedjson["textboxvalue"] as string;
        if (deserilizedjson.ContainsKey("color"))
            UserControlTask.BackColor = System.Drawing.ColorTranslator.FromHtml(deserilizedjson["color"] as string);
        return; 
       
    }

    #region Executing the task
    protected void execute_Clicked(object sender, EventArgs args)
    {
        base.Start(TextBox1.Text);
    }
    #endregion

    #region UserControlTaskPanel Overrides - ExecuteTask
    public override object ExecuteTask(object parameters)
    {
        string textBoxValue = parameters as string;

        DateTime now = DateTime.Now;
        string heading = string.Format("The time on the server is {0}:{1:d2}:{2:d2}", now.Hour, now.Minute, now.Second);
        string detail = string.Format("The value in the text box is: {0}", textBoxValue);

        ESRI.ArcGIS.ADF.Web.UI.WebControls.SimpleTaskResult result = new ESRI.ArcGIS.ADF.Web.UI.WebControls.SimpleTaskResult(heading, detail);
        return result;
    }
    #endregion
}