protected override void OnFormBound()
    {
        base.OnFormBound();

        if (IsActivating)
        {
            ResetForm();
            SetValuesFromEntityHistory();
            ClientBindingMgr.SetFocusTo(rbContact);
        }

        btnContinue.Enabled    = NewUnscheduledActivity.Checked;
        OpenActivities.Visible = false;

        if (CompleteScheduledActivity.Checked)
        {
            LookupControl lookup = GetBoundLookup();
            Session["entityName"] = lookup != null ? lookup.LookupEntityName : null;
            Session["entityId"]   = lookup != null?GetId(lookup.LookupResultValue) : null;

            OpenActivities.DataBind();
            OpenActivities.Visible = OpenActivities.Rows.Count > 0;
        }
        if (Account.LookupResultValue != null)
        {
            SetSeedValues();
        }
        if (LeadId.LookupResultValue == null)
        {
            Company.Text = string.Empty;
        }
    }
    protected override void OnFormBound()
    {
        base.OnFormBound();

        if (IsActivating)
        {
            ResetForm();
            SetValuesFromEntityHistory();
            ClientBindingMgr.SetFocusTo(rbContact);
        }

        btnContinue.Enabled = NewUnscheduledActivity.Checked;
        divResults.Visible  = false;

        if (CompleteScheduledActivity.Checked)
        {
            LookupControl lookup = GetBoundLookup();
            Session["entityName"] = lookup != null ? lookup.LookupEntityName : null;
            Session["entityId"]   = lookup != null?GetId(lookup.LookupResultValue) : null;

            OpenActivities.DataBind();
            divResults.Visible = true;
        }
        if (Account.LookupResultValue != null)
        {
            SetSeedValues();
        }
        if (LeadId.LookupResultValue == null)
        {
            Company.Text = string.Empty;
        }

        ScriptManager.RegisterClientScriptInclude(this, GetType(), "ScheduleCompleteActivity", Page.ResolveUrl("~/SmartParts/Activity/ScheduleCompleteActivity.js"));
        var script = new StringBuilder();

        if (Page.IsPostBack)
        {
            script.Append(" Sage.UI.Forms.ScheduleCompleteActivity.init(" + GetWorkSpace() + " );");
        }
        else
        {
            script.Append("require(['dojo/ready'], function(ready) { " +
                          "ready(function () { Sage.UI.Forms.ScheduleCompleteActivity.init(" + GetWorkSpace() + "); }); " +
                          "});");
        }
        ScriptManager.RegisterStartupScript(this, GetType(), "initialize_ScheduleCompleteActivity", script.ToString(), true);
    }