/// <summary> /// Returns <see cref="IFormObject"/> as an HTML string with or without HTML headers. /// </summary> /// <param name="formObject"></param> /// <param name="includeHtmlHeaders"></param> /// <returns></returns> public static string TransformToHtmlString(IFormObject formObject, bool includeHtmlHeaders) { if (formObject == null) { throw new ArgumentNullException(nameof(formObject), ScriptLinkHelpers.GetLocalizedString("parameterCannotBeNull", CultureInfo.CurrentCulture)); } StringBuilder sb = new StringBuilder(); sb.Append(GetHeader(formObject.GetType().ToString(), includeHtmlHeaders)); sb.Append(GetHtmlForObject(formObject, HtmlOutputType.Table)); sb.Append(AddRowTables(formObject, 2)); sb.Append(GetFooter(includeHtmlHeaders)); return(sb.ToString()); }
/// <summary> /// Returns <see cref="IFormObject"/> as an HTML string with or without HTML headers. /// </summary> /// <param name="formObject"></param> /// <param name="includeHtmlHeaders"></param> /// <returns></returns> public static string TransformToHtmlString(IFormObject formObject, bool includeHtmlHeaders) { if (formObject == null) { throw new ArgumentNullException("Parameter cannot be null.", "formObject"); } string html = ""; html += includeHtmlHeaders ? GetHtmlHeader() : ""; html += GetPageHeader(formObject.GetType().ToString()); html += GetHtmlForObject(formObject, HtmlOutputType.Table); html += "<h2>CurrentRow</h2>"; html += GetHtmlForObject(formObject.CurrentRow, HtmlOutputType.Table); if (formObject.CurrentRow != null && formObject.CurrentRow.Fields != null) { html += "<h3>Fields</h3>"; html += "<table>"; html += GetHtmlForObject(formObject.CurrentRow.Fields.FirstOrDefault(), HtmlOutputType.TableHeaders); foreach (FieldObject fieldObject in formObject.CurrentRow.Fields) { html += GetHtmlForObject(fieldObject, HtmlOutputType.TableRow); } html += "</table>"; } html += "<h2>OtherRows</h2>"; foreach (RowObject rowObject in formObject.OtherRows) { html += "<h3>Row</h3>"; html += GetHtmlForObject(rowObject, HtmlOutputType.Table); html += "<h4>Fields</h4>"; html += "<table>"; html += GetHtmlForObject(formObject.CurrentRow.Fields.FirstOrDefault(), HtmlOutputType.TableHeaders); foreach (FieldObject fieldObject in formObject.CurrentRow.Fields) { html += GetHtmlForObject(fieldObject, HtmlOutputType.TableRow); } html += "</table>"; } html += includeHtmlHeaders ? GetHtmlFooter() : ""; return(html); }