public static bool Valid(List <QuestionWebControl> questionControls, FormGenerationSettings settings) { var valid = true; foreach (var qc in questionControls) { if (!qc.Question.IsMandatory) { continue; } if (string.IsNullOrEmpty(qc.Value)) { qc.ErrorLabel.Text = WidgetActionFactory.getWidgetActionByName(qc.Question.ControlType).MandatoryQuestionErrorMessage(settings); qc.ErrorLabel.Visible = true; valid = false; } else if (qc.Value.Length > qc.Question.MaxSize) { qc.ErrorLabel.Text = settings.UserAnswerLengthErrorMessage; qc.ErrorLabel.Visible = true; valid = false; } } return(valid); }
protected override void OnInit(EventArgs e) { Control = WidgetActionFactory.getWidgetActionByName(Question.ControlType).QuestionWebControlAction(Question); ErrorLabel = new Label { Visible = false, CssClass = "has-error server-control" }; base.OnInit(e); }
public static List <Question> QuestionsWebControlToQuestions(List <QuestionWebControl> ctrls) { var questions = new List <Question>(); foreach (var ctrl in ctrls) { WidgetActionFactory.getWidgetActionByName(ctrl.Question.ControlType).SetQuestionAnswer( ctrl.Question, ctrl.Value ); questions.Add(ctrl.Question); } return(questions); }