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;
}
}