Exemple #1
0
        /// <summary>
        /// Loads the data saved in the form profile and fills all the fields with related info
        /// </summary>
        public void LoadSavedData(Control ParentControl, FormRequest SavedData)
        {
            if (ParentControl.Controls.Count == 0)
            {
                return;
            }

            foreach (Control ctrl in ParentControl.Controls)
            {
                LoadSavedData(ctrl, SavedData);
                HtmlControl _ctrl = ctrl as HtmlControl;
                if (_ctrl == null || _ctrl.ID == null)
                {
                    continue;
                }

                SetValue(_ctrl, SavedData.Get(_ctrl.ID));
            }
        }
Exemple #2
0
        public void SetValue(HtmlControl ctrl, string v)
        {
            switch (ctrl.GetType().Name)
            {
            case "HtmlInputHidden":
            case "HtmlInputText":
            case "HtmlInputPassword":
            case "BoundedHiddenElement":
            case "BoundedTextField":
            case "HtmlInputGenericControl":
                HtmlInputControl _input = ctrl as HtmlInputControl;
                _input.Value = v;
                break;

            case "HtmlTextArea":
            case "BoundedRichTextEditor":
            case "BoundedTextArea":
                HtmlTextArea textArea = ctrl as HtmlTextArea;
                textArea.Value = v;
                break;

            case "HtmlSelect":
            case "BoundedSelectList":
                HtmlSelect select = ctrl as HtmlSelect;
                select.Value = v;
                break;

            case "HtmlInputCheckBox":
            case "BoundedCheckbox":
                HtmlInputCheckBox checkbox = ctrl as HtmlInputCheckBox;
                checkbox.Checked = !string.IsNullOrWhiteSpace(v) && (checkbox.Value == v || v == "on");
                break;

            case "HtmlInputRadioButton":
                HtmlInputRadioButton radio = ctrl as HtmlInputRadioButton;
                Regex r = new Regex(":[a-z_0-9]*$", RegexOptions.IgnoreCase);
                v             = Request.Get(radio.Name);
                radio.Checked = radio.Value == v;
                break;
            }
        }