/// <summary> /// Creates the control(s) neccessary for prompting user for a new value /// </summary> /// <param name="configurationValues">The configuration values.</param> /// <param name="id"></param> /// <returns> /// The control /// </returns> public override Control EditControl( Dictionary<string, ConfigurationValue> configurationValues, string id ) { var picker = new CategoryPicker { ID = id, AllowMultiSelect = true }; if ( configurationValues != null ) { if ( configurationValues.ContainsKey( ENTITY_TYPE_NAME_KEY ) ) { string entityTypeName = configurationValues[ENTITY_TYPE_NAME_KEY].Value; if ( !string.IsNullOrWhiteSpace( entityTypeName ) && entityTypeName != None.IdValue ) { picker.EntityTypeName = entityTypeName; if ( configurationValues.ContainsKey( QUALIFIER_COLUMN_KEY ) ) { picker.EntityTypeQualifierColumn = configurationValues[QUALIFIER_COLUMN_KEY].Value; if ( configurationValues.ContainsKey( QUALIFIER_VALUE_KEY ) ) { picker.EntityTypeQualifierValue = configurationValues[QUALIFIER_VALUE_KEY].Value; } } } } } return picker; }
/// <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; } }
/// <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(); _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. Please select a different key value."; Controls.Add( _cvKey ); _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 ); _ddlFieldType = new RockDropDownList(); _ddlFieldType.ID = "ddlFieldType"; _ddlFieldType.Label = "Field Type"; _ddlFieldType.AutoPostBack = true; _ddlFieldType.SelectedIndexChanged += _ddlFieldType_SelectedIndexChanged; Controls.Add( _ddlFieldType ); if ( !Page.IsPostBack ) { _ddlFieldType.DataValueField = "Id"; _ddlFieldType.DataTextField = "Name"; _ddlFieldType.DataSource = new FieldTypeService() .Queryable() .OrderBy( a => a.Name ) .Select( a => new { a.Id, a.Name } ).ToList(); ; _ddlFieldType.DataBind(); } _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 ); _tbName.Attributes["onblur"] = string.Format( "populateAttributeKey('{0}','{1}')", _tbName.ClientID, _tbKey.ClientID ); _controlsLoaded = true; } }
/// <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(); _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. Please select a different key value."; Controls.Add(_cvKey); _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); _ddlFieldType = new RockDropDownList(); _ddlFieldType.ID = "ddlFieldType"; _ddlFieldType.Label = "Field Type"; _ddlFieldType.AutoPostBack = true; _ddlFieldType.SelectedIndexChanged += _ddlFieldType_SelectedIndexChanged; Controls.Add(_ddlFieldType); if (!Page.IsPostBack) { _ddlFieldType.DataValueField = "Id"; _ddlFieldType.DataTextField = "Name"; _ddlFieldType.DataSource = new FieldTypeService() .Queryable() .OrderBy(a => a.Name) .Select(a => new { a.Id, a.Name }).ToList();; _ddlFieldType.DataBind(); } _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); _tbName.Attributes["onblur"] = string.Format("populateAttributeKey('{0}','{1}')", _tbName.ClientID, _tbKey.ClientID); _controlsLoaded = true; } }
/// <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; } }