/// <summary> /// Sets selected item of the <see cref="DropDownList"/> or text of the <see cref="TextBoxControl"/> based on the given <paramref name="value"/>. /// </summary> /// <param name="value">Value to be set</param> protected override void SetControlValue(object value) { LoadAndSelectList(); if (FieldInfo != null) { value = ConvertInputValue(value); } string selectedValue = ValidationHelper.GetString(value, String.Empty); if (value != null) { EnsureActualValueAsItem(selectedValue); } if (EditText) { txtCombo.Text = selectedValue; } else { dropDownList.ClearSelection(); FormControlsHelper.SelectSingleValue(selectedValue, dropDownList, !CaseSensitiveSelection); } }
/// <summary> /// Init event handler /// </summary> protected override void OnInit(EventArgs e) { base.OnInit(e); Save += btnOK_Click; ElementID = QueryHelper.GetString("elementid", ""); if (!RequestHelper.IsPostBack()) { // Load the initialization script which pulls the value from the opener ScriptHelper.RegisterStartupScript(this, typeof(string), "LoadValue", ScriptHelper.GetScript(String.Format( "document.getElementById('{0}').value = wopener.document.getElementById('{1}').value; {2}", hdnValue.ClientID, ElementID, ClientScript.GetPostBackEventReference(btnLoad, null) ))); } else { // Load the form control string formControl = QueryHelper.GetString("formcontrol", ""); // Load the form control var ctrl = FormControlsHelper.LoadFormControl(Page, formControl, ""); if (ctrl != null) { plcControl.Controls.Add(ctrl); } FormControl = ctrl; } }
/// <summary> /// Loads field with values from FormFieldInfo. /// </summary> public void Reload() { if (FieldInfo != null) { bool isMacro; txtDescription.SetValue(FieldInfo.GetPropertyValue(FormFieldPropertyEnum.FieldDescription, out isMacro), isMacro); txtFieldCaption.SetValue(FieldInfo.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, out isMacro), isMacro); txtExplanationText.SetValue(FieldInfo.GetPropertyValue(FormFieldPropertyEnum.ExplanationText, out isMacro), isMacro); if (ShowInheritanceSettings) { chkControlInheritable.Checked = FieldInfo.Inheritable; } // Field visibility if (ShowFieldVisibility) { chkChangeVisibility.Checked = FieldInfo.AllowUserToChangeVisibility; Visibility = FieldInfo.Visibility; // Load controls for user visibility drpVisibilityControl.DataSource = FormUserControlInfoProvider.GetFormUserControls("UserControlCodeName, UserControlDisplayName", "UserControlForVisibility = 1", "UserControlDisplayName"); drpVisibilityControl.DataBind(); FormControlsHelper.SelectSingleValue(FieldInfo.VisibilityControl, drpVisibilityControl, true); } plcVisibility.Visible = ShowFieldVisibility; if ((Mode == FieldEditorModeEnum.BizFormDefinition) || (Mode == FieldEditorModeEnum.AlternativeBizFormDefinition)) { chkPublicField.Checked = FieldInfo.PublicField; } string selectedItem; // Get control name from settings if (!String.IsNullOrEmpty(Convert.ToString(FieldInfo.Settings["controlname"]))) { selectedItem = Convert.ToString(FieldInfo.Settings["controlname"]); } // Or get control name from field type else { selectedItem = FormHelper.GetFormFieldControlTypeString(FieldInfo.FieldType); } var fi = FormUserControlInfoProvider.GetFormUserControlInfo(selectedItem); FieldType = (fi != null) ? selectedItem : FormHelper.GetFormFieldDefaultControlType(AttributeType, GetControlsToDisplay()); LoadFieldTypes(FieldInfo.PrimaryKey); } // If FormFieldInfo is not specified then clear form else { chkPublicField.Checked = true; ctrlVisibility.Value = null; drpVisibilityControl.ClearSelection(); chkChangeVisibility.Checked = false; txtFieldCaption.SetValue(null); txtDescription.SetValue(null); txtExplanationText.SetValue(null); drpControl.Reload(false); drpControl.Value = FormHelper.GetFormFieldDefaultControlType(AttributeType, GetControlsToDisplay()); } }