コード例 #1
0
        /// <summary>
        /// Called by the ASP.NET page framework to notify server controls that use composition-based implementation to create any child controls they contain in preparation for posting back or rendering.
        /// </summary>
        protected override void CreateChildControls()
        {
            if ( !_controlsLoaded )
            {
                Controls.Clear();

                _hfExistingKeyNames = new HtmlInputHidden();
                _hfExistingKeyNames.AddCssClass( "js-existing-key-names" );
                _hfExistingKeyNames.ID = this.ID + "_hfExistingKeyNames";
                Controls.Add( _hfExistingKeyNames );

                _lAttributeActionTitle = new Literal();
                _lAttributeActionTitle.ID = "lAttributeActionTitle";
                Controls.Add( _lAttributeActionTitle );

                _validationSummary = new ValidationSummary();
                _validationSummary.ID = "valiationSummary";
                _validationSummary.CssClass = "alert alert-danger";
                _validationSummary.HeaderText = "Please Correct the Following";
                Controls.Add( _validationSummary );

                _tbName = new RockTextBox();
                _tbName.ID = "tbName";
                _tbName.Label = "Name";
                _tbName.Required = true;
                Controls.Add( _tbName );

                _tbDescription = new RockTextBox();
                _tbDescription.Label = "Description";
                _tbDescription.ID = "tbDescription";
                _tbDescription.TextMode = TextBoxMode.MultiLine;
                _tbDescription.Rows = 3;
                Controls.Add( _tbDescription );

                _cpCategories = new CategoryPicker();
                _cpCategories.ID = "cpCategories_" + this.ID.ToString();
                _cpCategories.Label = "Categories";
                _cpCategories.AllowMultiSelect = true;
                _cpCategories.EntityTypeId = EntityTypeCache.Read( typeof( Rock.Model.Attribute ) ).Id;
                _cpCategories.EntityTypeQualifierColumn = "EntityTypeId";
                Controls.Add( _cpCategories );

                _tbKey = new RockTextBox();
                _tbKey.ID = "tbKey";
                _tbKey.Label = "Key";
                _tbKey.Required = true;
                Controls.Add( _tbKey );

                _cvKey = new CustomValidator();
                _cvKey.ID = "cvKey";
                _cvKey.ControlToValidate = _tbKey.ID;
                _cvKey.ClientValidationFunction = "validateKey";
                _cvKey.ServerValidate += cvKey_ServerValidate;
                _cvKey.Display = ValidatorDisplay.Dynamic;
                _cvKey.CssClass = "validation-error help-inline";
                _cvKey.ErrorMessage = "There is already an existing property with the key value you entered or the key has illegal characters. Please select a different key value and use only letters, numbers and underscores.";
                Controls.Add( _cvKey );

                _tbIconCssClass = new RockTextBox();
                _tbIconCssClass.ID = "_tbIconCssClass";
                _tbIconCssClass.Label = "Icon CSS Class";
                Controls.Add( _tbIconCssClass );

                _cbRequired = new RockCheckBox();
                _cbRequired.ID ="cbRequired";
                _cbRequired.Label = "Required";
                _cbRequired.Text = "Require a value";
                Controls.Add( _cbRequired );

                _cbShowInGrid = new RockCheckBox();
                _cbShowInGrid.ID = "cbShowInGrid";
                _cbShowInGrid.Label = "Show in Grid";
                _cbShowInGrid.Text = "Yes";
                _cbShowInGrid.Help = "If selected, this attribute will be included in a grid.";
                Controls.Add( _cbShowInGrid );

                _cbAllowSearch = new RockCheckBox();
                _cbAllowSearch.ID = "cbAllowSearch";
                _cbAllowSearch.Label = "Allow Search";
                _cbAllowSearch.Text = "Yes";
                _cbAllowSearch.Help = "If selected, this attribute can be search on.";
                _cbAllowSearch.Visible = false;  // Default is to not show this option
                Controls.Add( _cbAllowSearch );

                _ddlFieldType = new RockDropDownList();
                _ddlFieldType.ID = "ddlFieldType";
                _ddlFieldType.Label = "Field Type";
                _ddlFieldType.AutoPostBack = true;
                _ddlFieldType.SelectedIndexChanged += _ddlFieldType_SelectedIndexChanged;
                _ddlFieldType.DataValueField = "Id";
                _ddlFieldType.DataTextField = "Name";
                Controls.Add( _ddlFieldType );

                _phQualifiers = new PlaceHolder();
                _phQualifiers.ID = "phQualifiers";
                _phQualifiers.EnableViewState = false;
                Controls.Add( _phQualifiers );

                _phDefaultValue = new PlaceHolder();
                _phDefaultValue.ID = "phDefaultValue";
                _phDefaultValue.EnableViewState = false;
                Controls.Add( _phDefaultValue );

                _btnSave = new LinkButton();
                _btnSave.ID = "btnSave";
                _btnSave.Text = "OK";
                _btnSave.CssClass = "btn btn-primary";
                _btnSave.Click += btnSave_Click;
                Controls.Add( _btnSave );

                _btnCancel = new LinkButton();
                _btnCancel.ID = "btnCancel";
                _btnCancel.Text = "Cancel";
                _btnCancel.CssClass = "btn btn-link";
                _btnCancel.CausesValidation = false;
                _btnCancel.Click += btnCancel_Click;
                Controls.Add( _btnCancel );

                _controlsLoaded = true;
            }
        }
コード例 #2
0
ファイル: ValueList.cs プロジェクト: Ganon11/Rock
        /// <summary>
        /// Renders the base control.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public virtual void RenderBaseControl( HtmlTextWriter writer )
        {
            Dictionary<string, string> definedValues = null;
            if ( DefinedTypeId.HasValue )
            {
                definedValues = new Dictionary<string, string>();
                new DefinedValueService( new RockContext() )
                    .GetByDefinedTypeId( DefinedTypeId.Value )
                    .ToList()
                    .ForEach( v => definedValues.Add( v.Id.ToString(), v.Value ) );
            }
            else if ( CustomValues != null )
            {
                definedValues = CustomValues;
            }

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "value-list" );
            writer.RenderBeginTag( HtmlTextWriterTag.Span );
            writer.WriteLine();

            _hfValue.RenderControl( writer );
            writer.WriteLine();

            StringBuilder valueHtml = new StringBuilder();
            valueHtml.Append( @"<div class=""controls controls-row form-control-group"">");
            if ( definedValues != null )
            {
                valueHtml.Append( @"<select class=""form-control input-width-lg js-value-list-input""><option value=""""></option>" );
                foreach ( var definedValue in definedValues )
                {
                    valueHtml.AppendFormat( @"<option value=""{0}"">{1}</option>", definedValue.Key, definedValue.Value );
                }
                valueHtml.Append( @"</select>" );
            }
            else
            {
                valueHtml.AppendFormat( @"<input class=""form-control input-width-lg js-value-list-input"" type=""text"" placeholder=""{0}""></input>", ValuePrompt );
            }
            valueHtml.Append( @"<a href=""#"" class=""btn btn-sm btn-danger value-list-remove""><i class=""fa fa-minus-circle""></i></a></div>" );

            var hfValueHtml = new HtmlInputHidden();
            hfValueHtml.AddCssClass( "js-value-list-html" );
            hfValueHtml.Value = valueHtml.ToString();
            hfValueHtml.RenderControl( writer );

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "value-list-rows" );
            writer.RenderBeginTag( HtmlTextWriterTag.Span );
            writer.WriteLine();

            string[] values = this.Value.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries );
            foreach ( string value in values )
            {
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "controls controls-row form-control-group" );
                writer.RenderBeginTag( HtmlTextWriterTag.Div );
                writer.WriteLine();

                if ( definedValues != null )
                {
                    DropDownList ddl = new DropDownList();
                    ddl.AddCssClass( "form-control input-width-lg js-value-list-input" );
                    ddl.DataTextField = "Value";
                    ddl.DataValueField = "Key";
                    ddl.DataSource = definedValues;
                    ddl.DataBind();
                    ddl.Items.Insert( 0, new ListItem( string.Empty, string.Empty ) );
                    ddl.SelectedValue = value;
                    ddl.RenderControl( writer );
                }
                else
                {
                    writer.AddAttribute( HtmlTextWriterAttribute.Class, "form-control input-width-lg js-value-list-input" );
                    writer.AddAttribute( HtmlTextWriterAttribute.Type, "text" );
                    writer.AddAttribute( "placeholder", ValuePrompt );
                    writer.AddAttribute( HtmlTextWriterAttribute.Value, value );
                    writer.RenderBeginTag( HtmlTextWriterTag.Input );
                    writer.RenderEndTag();
                }

                writer.Write( " " );
                writer.WriteLine();

                // Write Remove Button
                writer.AddAttribute( HtmlTextWriterAttribute.Href, "#" );
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "btn btn-sm btn-danger value-list-remove" );
                writer.RenderBeginTag( HtmlTextWriterTag.A );
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "fa fa-minus-circle");
                writer.RenderBeginTag( HtmlTextWriterTag.I );
                writer.RenderEndTag();
                writer.RenderEndTag();
                writer.WriteLine();

                writer.RenderEndTag();
                writer.WriteLine();

            }

            writer.RenderEndTag();
            writer.WriteLine();

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "actions" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "btn btn-action btn-xs value-list-add" );
            writer.AddAttribute( HtmlTextWriterAttribute.Href, "#" );
            writer.RenderBeginTag( HtmlTextWriterTag.A );
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "fa fa-plus-circle");
            writer.RenderBeginTag( HtmlTextWriterTag.I );

            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.WriteLine();

            writer.RenderEndTag();
            writer.WriteLine();

            RegisterClientScript();
        }
コード例 #3
0
        /// <summary>
        /// Renders the base control.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public override void RenderBaseControl( HtmlTextWriter writer )
        {
            Dictionary<string, string> values = null;
            if ( DefinedTypeId.HasValue )
            {
                values = new Dictionary<string, string>();
                new DefinedValueService( new RockContext() )
                    .GetByDefinedTypeId( DefinedTypeId.Value )
                    .ToList()
                    .ForEach( v => values.Add( v.Id.ToString(), v.Value ) );
            }
            else if ( CustomValues != null )
            {
                values = CustomValues;
            }

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "key-value-list " + this.CssClass );
            writer.AddAttribute( HtmlTextWriterAttribute.Id, this.ClientID );
            writer.RenderBeginTag( HtmlTextWriterTag.Span );
            writer.WriteLine();

            _hfValue.RenderControl( writer );
            writer.WriteLine();

            StringBuilder html = new StringBuilder();
            html.Append( @"<div class=""controls controls-row form-control-group"">");

            // write key/value html
            if ( this.DisplayValueFirst )
            {
                WriteValueHtml( html, values );
                WriteKeyHtml( html );
            }
            else
            {
                WriteKeyHtml( html );
                WriteValueHtml( html, values );
            }

            html.Append( @"<a href=""#"" class=""btn btn-sm btn-danger key-value-remove""><i class=""fa fa-minus-circle""></i></a></div>" );

            var hfValueHtml = new HtmlInputHidden();
            hfValueHtml.AddCssClass( "js-value-html" );
            hfValueHtml.Value = html.ToString();
            hfValueHtml.RenderControl( writer );

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "key-value-rows" );
            writer.RenderBeginTag( HtmlTextWriterTag.Span );
            writer.WriteLine();

            string[] nameValues = this.Value.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries );
            foreach ( string nameValue in nameValues )
            {
                string[] nameAndValue = nameValue.Split( new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries );

                writer.AddAttribute( HtmlTextWriterAttribute.Class, "controls controls-row form-control-group" );
                writer.RenderBeginTag( HtmlTextWriterTag.Div );
                writer.WriteLine();

                if ( DisplayValueFirst )
                {
                    WriteValueControls( writer, nameAndValue, values );
                    WriteKeyControls( writer, nameAndValue );
                }
                else
                {
                    WriteKeyControls( writer, nameAndValue );
                    WriteValueControls( writer, nameAndValue, values );
                }

                // Write Remove Button
                writer.AddAttribute( HtmlTextWriterAttribute.Href, "#" );
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "btn btn-sm btn-danger key-value-remove" );
                writer.RenderBeginTag( HtmlTextWriterTag.A );
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "fa fa-minus-circle");
                writer.RenderBeginTag( HtmlTextWriterTag.I );
                writer.RenderEndTag();
                writer.RenderEndTag();
                writer.WriteLine();

                writer.RenderEndTag();
                writer.WriteLine();

            }

            writer.RenderEndTag();
            writer.WriteLine();

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "actions" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "btn btn-action btn-xs key-value-add" );
            writer.AddAttribute( HtmlTextWriterAttribute.Href, "#" );
            writer.RenderBeginTag( HtmlTextWriterTag.A );
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "fa fa-plus-circle");
            writer.RenderBeginTag( HtmlTextWriterTag.I );

            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.WriteLine();

            writer.RenderEndTag();
            writer.WriteLine();

            RegisterClientScript();
        }
コード例 #4
0
        /// <summary>
        /// Outputs server control content to a provided <see cref="T:System.Web.UI.HtmlTextWriter" /> object and stores tracing information about the control if tracing is enabled.
        /// </summary>
        /// <param name="writer">The <see cref="T:System.Web.UI.HtmlTextWriter" /> object that receives the control content.</param>
        public override void RenderControl( HtmlTextWriter writer )
        {
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "form-action-list form-group" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );

            _hfValue.RenderControl( writer );

            StringBuilder valueHtml = new StringBuilder();
            valueHtml.Append( @"<div class=""row"">" );
            valueHtml.Append( @"<div class=""col-sm-2""><input class=""form-action-key form-control js-form-action-input"" type=""text"" placeholder=""Action""></input></div>" );
            valueHtml.Append( @"<div class=""col-sm-2""><select class=""form-action-button form-control js-form-action-input"">" );
            var definedType = Rock.Web.Cache.DefinedTypeCache.Read( Rock.SystemGuid.DefinedType.BUTTON_HTML.AsGuid() );
            foreach ( var definedValue in definedType.DefinedValues )
            {
                valueHtml.AppendFormat( @"<option value=""{0}"">{1}</option>", definedValue.Guid.ToString(), definedValue.Value );
            }
            valueHtml.Append( @"</select></div>" );
            valueHtml.Append( @"<div class=""col-sm-3""><select class=""form-action-value form-control js-form-action-input""><option value=""""></option>" );
            foreach ( var activity in Activities )
            {
                valueHtml.AppendFormat( @"<option value=""{0}"">{1}</option>", activity.Key, activity.Value );
            }
            valueHtml.Append( @"</select></div>" );
            valueHtml.Append( @"<div class=""col-sm-4""><input class=""form-action-response form-control js-form-action-input"" type=""text"" placeholder=""Response Text""></input></div>" );
            valueHtml.Append( @"<div class=""col-sm-1""><a href=""#"" class=""btn btn-sm btn-danger form-action-remove""><i class=""fa fa-minus-circle""></i></a></div></div>" );

            var hfValueHtml = new HtmlInputHidden();
            hfValueHtml.AddCssClass( "js-value-html" );
            hfValueHtml.Value = valueHtml.ToString();
            hfValueHtml.RenderControl( writer );

            // Write Header row
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "row" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );

            // Write Action
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-sm-2" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "control-label" );
            writer.RenderBeginTag( HtmlTextWriterTag.Label );
            writer.Write( "Command Label" );
            writer.RenderEndTag();
            writer.RenderEndTag();

            // Write Css
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-sm-2" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "control-label" );
            writer.RenderBeginTag( HtmlTextWriterTag.Label );
            writer.Write( "Button Type" );
            writer.RenderEndTag();
            writer.RenderEndTag();

            // Write Activity Value
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-sm-3" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "control-label" );
            writer.RenderBeginTag( HtmlTextWriterTag.Label );
            writer.Write( "Activate Activity" );
            writer.RenderEndTag();
            writer.RenderEndTag();

            // Write Response
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-sm-4" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "control-label" );
            writer.RenderBeginTag( HtmlTextWriterTag.Label );
            writer.Write( "Response Text" );
            writer.RenderEndTag();
            writer.RenderEndTag();

            // Write Remove Button
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-sm-1" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );
            writer.RenderEndTag();  // Div

            writer.RenderEndTag();  // Div.row

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "form-action-rows" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );
            writer.WriteLine();

            for (int i = 0; i < _actionControls.Count; i++)
            {
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "row" );
                writer.RenderBeginTag( HtmlTextWriterTag.Div );

                // Write Action
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-sm-2" );
                writer.RenderBeginTag( HtmlTextWriterTag.Div );
                _actionControls[i].RenderControl( writer );
                writer.RenderEndTag();

                // Write Button Type
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-sm-2" );
                writer.RenderBeginTag( HtmlTextWriterTag.Div );
                _buttonHtmlControls[i].RenderControl( writer );
                writer.RenderEndTag();

                // Write Activity Value
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-sm-3" );
                writer.RenderBeginTag( HtmlTextWriterTag.Div );
                _activityControls[i].RenderControl( writer );
                writer.RenderEndTag();

                // Write Response
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-sm-4" );
                writer.RenderBeginTag( HtmlTextWriterTag.Div );
                _responseControls[i].RenderControl( writer );
                writer.RenderEndTag();

                // Write Remove Button
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "col-sm-1" );
                writer.RenderBeginTag( HtmlTextWriterTag.Div );
                writer.AddAttribute( HtmlTextWriterAttribute.Href, "#" );
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "btn btn-sm btn-danger form-action-remove" );
                writer.RenderBeginTag( HtmlTextWriterTag.A );
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "fa fa-minus-circle" );
                writer.RenderBeginTag( HtmlTextWriterTag.I );
                writer.RenderEndTag();  // I
                writer.RenderEndTag();  // A
                writer.RenderEndTag();  // Div

                writer.RenderEndTag();  // Div.row
            }

            writer.RenderEndTag();      // Div.form-action-rows

            // Add Actions
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "actions" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "btn btn-action btn-xs form-action-add" );
            writer.AddAttribute( HtmlTextWriterAttribute.Href, "#" );
            writer.RenderBeginTag( HtmlTextWriterTag.A );
            writer.AddAttribute( HtmlTextWriterAttribute.Class, "fa fa-plus-circle" );
            writer.RenderBeginTag( HtmlTextWriterTag.I );
            writer.RenderEndTag();      // I
            writer.RenderEndTag();      // A
            writer.RenderEndTag();      // Div.actions

            writer.RenderEndTag();      // Div.form-action-list

            RegisterClientScript();
        }
コード例 #5
0
        /// <summary>
        /// Renders the base control.
        /// </summary>
        /// <param name="writer">The writer.</param>
        public override void RenderBaseControl( HtmlTextWriter writer )
        {
            Dictionary<string, string> values = null;
            if ( DefinedTypeId.HasValue )
            {
                values = new Dictionary<string, string>();
                new DefinedValueService( new RockContext() )
                    .GetByDefinedTypeId( DefinedTypeId.Value )
                    .ToList()
                    .ForEach( v => values.Add( v.Id.ToString(), v.Value ) );
            }
            else if ( CustomValues != null )
            {
                values = CustomValues;
            }

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "key-value-list " + this.CssClass );
            writer.AddAttribute( HtmlTextWriterAttribute.Id, this.ClientID );
            writer.RenderBeginTag( HtmlTextWriterTag.Span );
            writer.WriteLine();

            _hfValue.RenderControl( writer );
            writer.WriteLine();

            StringBuilder html = new StringBuilder();
            html.Append( @"<div class=""controls controls-row form-control-group"">");
            if ( CustomKeys != null && CustomKeys.Any() )
            {
                html.Append( @"<select class=""key-value-key form-control input-width-md js-key-value-input"">" );
                foreach ( var key in CustomKeys )
                {
                    html.AppendFormat( @"<option value=""{0}"">{1}</option>", key.Key, key.Value );
                }
                html.Append( @"</select>" );
            }
            else
            {
                html.AppendFormat( @"<input class=""key-value-key form-control input-width-md js-key-value-input"" type=""text"" placeholder=""{0}""></input> ", KeyPrompt );
            }

            if ( values != null )
            {
                html.Append( @"<select class=""key-value-value form-control input-width-md js-key-value-input"">" );
                foreach ( var value in values )
                {
                    html.AppendFormat( @"<option value=""{0}"">{1}</option>", value.Key, value.Value );
                }
                html.Append( @"</select>" );
            }
            else
            {
                html.AppendFormat( @"<input class=""key-value-value input-width-md form-control js-key-value-input"" type=""text"" placeholder=""{0}""></input>", ValuePrompt );
            }
            html.Append( @"<a href=""#"" class=""btn btn-sm btn-danger key-value-remove""><i class=""fa fa-minus-circle""></i></a></div>" );

            var hfValueHtml = new HtmlInputHidden();
            hfValueHtml.AddCssClass( "js-value-html" );
            hfValueHtml.Value = html.ToString();
            hfValueHtml.RenderControl( writer );

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "key-value-rows" );
            writer.RenderBeginTag( HtmlTextWriterTag.Span );
            writer.WriteLine();

            string[] nameValues = this.Value.Split( new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries );
            foreach ( string nameValue in nameValues )
            {
                string[] nameAndValue = nameValue.Split( new char[] { '^' }, StringSplitOptions.RemoveEmptyEntries );

                writer.AddAttribute( HtmlTextWriterAttribute.Class, "controls controls-row form-control-group" );
                writer.RenderBeginTag( HtmlTextWriterTag.Div );
                writer.WriteLine();

                // Write Key
                if ( CustomKeys != null && CustomKeys.Any() )
                {
                    DropDownList ddl = new DropDownList();
                    ddl.AddCssClass( "key-value-key form-control input-width-md js-key-value-input" );
                    ddl.DataTextField = "Value";
                    ddl.DataValueField = "Key";
                    ddl.DataSource = CustomKeys;
                    ddl.DataBind();
                    if ( nameAndValue.Length >= 1 )
                    {
                        ddl.SelectedValue = nameAndValue[0];
                    }
                    ddl.RenderControl( writer );
                }
                else
                {
                    // Write Name
                    writer.AddAttribute( HtmlTextWriterAttribute.Class, "key-value-key form-control input-width-md js-key-value-input" );
                    writer.AddAttribute( HtmlTextWriterAttribute.Type, "text" );
                    writer.AddAttribute( HtmlTextWriterAttribute.Value, nameAndValue.Length >= 1 ? nameAndValue[0] : string.Empty );
                    writer.AddAttribute( "placeholder", KeyPrompt );
                    writer.RenderBeginTag( HtmlTextWriterTag.Input );
                    writer.RenderEndTag();
                }

                writer.Write( " " );
                writer.WriteLine();

                // Write Value
                if ( values != null )
                {
                    DropDownList ddl = new DropDownList();
                    ddl.AddCssClass( "key-value-value form-control input-width-md js-key-value-input" );
                    ddl.DataTextField = "Value";
                    ddl.DataValueField = "Key";
                    ddl.DataSource = values;
                    ddl.DataBind();
                    if ( nameAndValue.Length >= 2 )
                    {
                        ddl.SelectedValue = nameAndValue[1];
                    }
                    ddl.RenderControl( writer );
                }
                else
                {
                    writer.AddAttribute( HtmlTextWriterAttribute.Class, "key-value-value form-control input-width-md js-key-value-input" );
                    writer.AddAttribute( HtmlTextWriterAttribute.Type, "text" );
                    writer.AddAttribute( HtmlTextWriterAttribute.Value, nameAndValue.Length >= 2 ? nameAndValue[1] : string.Empty );
                    writer.AddAttribute( "placeholder", ValuePrompt );
                    writer.RenderBeginTag( HtmlTextWriterTag.Input );
                    writer.RenderEndTag();
                }

                writer.Write( " " );
                writer.WriteLine();

                // Write Remove Button
                writer.AddAttribute( HtmlTextWriterAttribute.Href, "#" );
                writer.AddAttribute( HtmlTextWriterAttribute.Class, "btn btn-sm btn-danger key-value-remove" );
                writer.RenderBeginTag( HtmlTextWriterTag.A );
                writer.AddAttribute(HtmlTextWriterAttribute.Class, "fa fa-minus-circle");
                writer.RenderBeginTag( HtmlTextWriterTag.I );
                writer.RenderEndTag();
                writer.RenderEndTag();
                writer.WriteLine();

                writer.RenderEndTag();
                writer.WriteLine();

            }

            writer.RenderEndTag();
            writer.WriteLine();

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "actions" );
            writer.RenderBeginTag( HtmlTextWriterTag.Div );

            writer.AddAttribute( HtmlTextWriterAttribute.Class, "btn btn-action btn-xs key-value-add" );
            writer.AddAttribute( HtmlTextWriterAttribute.Href, "#" );
            writer.RenderBeginTag( HtmlTextWriterTag.A );
            writer.AddAttribute(HtmlTextWriterAttribute.Class, "fa fa-plus-circle");
            writer.RenderBeginTag( HtmlTextWriterTag.I );

            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.RenderEndTag();
            writer.WriteLine();

            writer.RenderEndTag();
            writer.WriteLine();

            RegisterClientScript();
        }