/// <summary> /// Renders the specified ph. /// </summary> /// <param name="placeHolder">The place holder.</param> /// <param name="readOnly">if set to <c>true</c> [read only].</param> /// <param name="showRequiredNotation">if set to <c>true</c> [show required notation].</param> /// <param name="validationProvider">The validation provider.</param> /// <param name="localizer">The text for the default option (signifying no choice).</param> public virtual void Render(PlaceHolder placeHolder, bool readOnly, bool showRequiredNotation, ValidationProviderBase validationProvider, ILocalizer localizer) { RenderSection(this, placeHolder, readOnly, showRequiredNotation, validationProvider, localizer); }
/// <summary> /// Renders the specified ph. /// </summary> /// <param name="section">The section.</param> /// <param name="ph">The placeholder container.</param> /// <param name="readOnly">if set to <c>true</c> [read only].</param> /// <param name="showRequiredNotation">if set to <c>true</c> [show required notation].</param> /// <param name="validationProvider">The validation provider.</param> /// <param name="localizer">Localizes text.</param> public static void RenderSection(ISection section, PlaceHolder ph, bool readOnly, bool showRequiredNotation, ValidationProviderBase validationProvider, ILocalizer localizer) { var sectionDiv = new HtmlGenericControl("DIV"); sectionDiv.Attributes["class"] = Engage.Survey.Util.Utility.CssClassSectionWrap + " section" + section.SectionId; ph.Controls.Add(sectionDiv); // row for the section text var title = new HtmlGenericControl("h3"); title.Attributes["class"] = Engage.Survey.Util.Utility.CssClassSectionTitle; title.InnerHtml = HttpUtility.HtmlEncode(section.FormattedText).Replace("\n", "<br />"); sectionDiv.Controls.Add(title); foreach (IQuestion question in section.GetQuestions()) { // create the question wrap div. var questionWrapDiv = new HtmlGenericControl("DIV"); questionWrapDiv.Attributes["class"] = "qw" + question.QuestionId; sectionDiv.Controls.Add(questionWrapDiv); // create the question span with label in it for question text. var questionSpan = new HtmlGenericControl("SPAN"); questionSpan.Attributes["class"] = Engage.Survey.Util.Utility.CssClassQuestion; questionSpan.InnerHtml = question.FormattedText; questionWrapDiv.Controls.Add(questionSpan); // <span class="questin">Phone<span>*</span></span> // if the question is required, then add the optional * notation. if (question.IsRequired && showRequiredNotation) { var requiredSpan = new HtmlGenericControl("SPAN"); requiredSpan.Attributes["class"] = Engage.Survey.Util.Utility.CssClassRequired; requiredSpan.InnerText = localizer.Localize("RequiredNotation.Text"); questionSpan.Controls.Add(requiredSpan); } // Create a span to put answer(s) in. Control control = Engage.Survey.Util.Utility.CreateWebControl(question, readOnly, string.Empty, localizer); questionWrapDiv.Controls.Add(control); if (string.IsNullOrEmpty(control.ID) || validationProvider == null) { continue; } // TODO: Localize error messages if (question.IsRequired && question.ControlType != ControlType.Checkbox) { validationProvider.RegisterValidator(ph.Page.ClientScript, ValidationType.RequiredField, "error-message", questionWrapDiv, control.ID, string.Format(localizer.Localize("RequiredError.Format"), question.UnformattedText), 1, 0); } switch (question.ControlType) { case ControlType.LargeTextInputField: case ControlType.SmallTextInputField: validationProvider.RegisterValidator(ph.Page.ClientScript, ValidationType.LimitedLengthField, "error-message", questionWrapDiv, control.ID, string.Format(localizer.Localize("TextLengthExceeded.Format"), question.UnformattedText), 1, 4000); break; case ControlType.EmailInputField: validationProvider.RegisterValidator(ph.Page.ClientScript, ValidationType.EmailField, "error-message", questionWrapDiv, control.ID, localizer.Localize("InvalidEmail.Text"), 1, 0); break; case ControlType.Checkbox: validationProvider.RegisterValidator(ph.Page.ClientScript, ValidationType.LimitedSelection, "error-message", questionWrapDiv, control.ID, string.Empty, question.SelectionLimit, 0); break; } } }
/// <summary> /// Static mechanism to render a survey. /// </summary> /// <param name="survey">The survey.</param> /// <param name="placeHolder">The place holder.</param> /// <param name="readOnly">if set to <c>true</c> [read only].</param> /// <param name="showRequiredNotation">if set to <c>true</c> [show required notation].</param> /// <param name="validationProvider">The validation provider.</param> /// <param name="localizer">Localizes text.</param> public static void RenderSurvey(ISurvey survey, PlaceHolder placeHolder, bool readOnly, bool showRequiredNotation, ValidationProviderBase validationProvider, ILocalizer localizer) { Debug.Assert(placeHolder != null, "placeHolder cannot be null"); Debug.Assert(validationProvider != null, "validationProvider cannot be null"); // add the survey title if (survey.ShowText) { var titleDiv = new HtmlGenericControl("DIV"); titleDiv.Attributes["class"] = Utility.CssClassSurveyTitle; titleDiv.InnerText = survey.Text; placeHolder.Controls.Add(titleDiv); } List <ISection> sections = survey.GetSections(); foreach (ISection s in sections) { s.Render(placeHolder, readOnly, showRequiredNotation, validationProvider, localizer); } }
/// <summary> /// Renders this survey section instance. /// </summary> /// <param name="placeHolder">The place holder.</param> /// <param name="readOnly">if set to <c>true</c> [read only].</param> /// <param name="showRequiredNotation">if set to <c>true</c> [show required notation].</param> /// <param name="validationProvider">The validation provider.</param> /// <param name="localizer">Localizes text.</param> public void Render(PlaceHolder placeHolder, bool readOnly, bool showRequiredNotation, ValidationProviderBase validationProvider, ILocalizer localizer) { Section.RenderSection(this, placeHolder, readOnly, showRequiredNotation, validationProvider, localizer); }
/// <summary> /// Renders the survey from this survey. /// </summary> /// <param name="placeHolder">The place holder.</param> /// <param name="readOnly">if set to <c>true</c> [read only].</param> /// <param name="showRequiredNotation">if set to <c>true</c> [show required notation].</param> /// <param name="validationProvider">The validation provider.</param> /// <param name="localizer">The text for the default option (signifying no choice).</param> public virtual void Render(PlaceHolder placeHolder, bool readOnly, bool showRequiredNotation, ValidationProviderBase validationProvider, ILocalizer localizer) { RenderSurvey(this, placeHolder, readOnly, showRequiredNotation, validationProvider, localizer); }
/// <summary> /// Static mechanism to render a survey. /// </summary> /// <param name="survey">The survey.</param> /// <param name="placeHolder">The place holder.</param> /// <param name="readOnly">if set to <c>true</c> [read only].</param> /// <param name="showRequiredNotation">if set to <c>true</c> [show required notation].</param> /// <param name="validationProvider">The validation provider.</param> /// <param name="localizer">Localizes text.</param> public static void RenderSurvey(ISurvey survey, PlaceHolder placeHolder, bool readOnly, bool showRequiredNotation, ValidationProviderBase validationProvider, ILocalizer localizer) { Debug.Assert(placeHolder != null, "placeHolder cannot be null"); Debug.Assert(validationProvider != null, "validationProvider cannot be null"); // add the survey title if (survey.ShowText) { var titleDiv = new HtmlGenericControl("DIV"); titleDiv.Attributes["class"] = Utility.CssClassSurveyTitle; titleDiv.InnerText = survey.Text; placeHolder.Controls.Add(titleDiv); } List<ISection> sections = survey.GetSections(); foreach (ISection s in sections) { s.Render(placeHolder, readOnly, showRequiredNotation, validationProvider, localizer); } }
/// <summary> /// Renders the survey from this survey. /// </summary> /// <param name="placeHolder">The place holder.</param> /// <param name="readOnly">if set to <c>true</c> [read only].</param> /// <param name="showRequiredNotation">if set to <c>true</c> [show required notation].</param> /// <param name="validationProvider">The validation provider.</param> /// <param name="localizer">Localizes text.</param> public void Render(PlaceHolder placeHolder, bool readOnly, bool showRequiredNotation, ValidationProviderBase validationProvider, ILocalizer localizer) { Survey.RenderSurvey(this, placeHolder, readOnly, showRequiredNotation, validationProvider, localizer); }