public static HtmlString ToHtmlTable <T>(this HtmlHelper htmlHelper, System.Data.DataTable datatable , object tableAttributes = null, object trAttributes = null, object tdAttributes = null , HtmlTableSetting HTMLTableSetting = null) { var html = datatable.ToHtmlTable(tableAttributes, trAttributes, tdAttributes, HTMLTableSetting); return(new HtmlString(html)); }
public static HtmlString ToHtmlTable <T>(this HtmlHelper htmlHelper, IEnumerable <T> enums , object tableAttributes = null, object trAttributes = null, object tdAttributes = null , HtmlTableSetting HTMLTableSetting = null) { var html = enums.ToHtmlTable(tableAttributes, trAttributes, tdAttributes, HTMLTableSetting); return(new HtmlString(html)); }
public void NonEncodeModeTest() { var expected = @"<table><thead><tr><th>Name</th></tr></thead><tbody><tr><td><b>ITWeiHan</b></td></tr></tbody></table>"; var htmltablesetting = new HtmlTableSetting() { IsHtmlEncodeMode = false }; var sourceData = new[] { new { Name = "<b>ITWeiHan</b>" } }; var html = sourceData.ToHtmlTable(HTMLTableSetting: htmltablesetting); Assert.AreEqual(expected, html); }
private static string ToHtmlTableByIEnumrable <T>(IEnumerable <T> enums, object tableAttributes = null, object tbAttributes = null, object trAttributes = null, object tdAttributes = null, object thAttributes = null, HtmlTableSetting HTMLTableSetting = null, HtmlTableHelperBuilder builder = null) { var htmltablegenerater = HtmlTableGeneraterFactory.CreateInstance(tableAttributes, trAttributes, tdAttributes, thAttributes, tbAttributes, HTMLTableSetting); htmltablegenerater._HtmlTableHelperBuilder = builder; // Q: Why not only IEnumerable<IDictionary> ? // A: Example Dapper Dynamic Query Only implement IDictionary<string,object> without IDictionary // Q: Why not use overload ToHtmlTable<TKey,TValue>(this IEnumerable<Dictionary<Tkey,TValue>> enums)? // A: Because ToHtmlTable<T>(this IEnumerable<T> enums) and ToHtmlTable<TKey,TValue>(this IEnumerable<Dictionary<Tkey,TValue>> enums) // System prefer use the former // ps. https://stackoverflow.com/questions/54251262/c-sharp-overload-key-value-and-non-key-value-type-using-var-without-specifying if (enums is IEnumerable <IDictionary <string, object> > ) //Special for Dapper Dynamic Query { return(htmltablegenerater.ToHtmlTableByKeyValue(enums as IEnumerable <IDictionary <string, object> >)); } else if (enums is IEnumerable <IDictionary> ) { return(htmltablegenerater.ToHtmlTableByKeyValue(enums as IEnumerable <IDictionary>)); } else { return(htmltablegenerater.ToHtmlTableByProperties(enums)); } }
public static string ToHtmlTable(this System.Data.DataTable datatable, object tableAttributes = null, object tbAttributes = null, object trAttributes = null, object tdAttributes = null, object thAttributes = null, HtmlTableSetting HTMLTableSetting = null) { var htmltablegenerater = HtmlTableGeneraterFactory.CreateInstance(tableAttributes, trAttributes, tdAttributes, thAttributes, tbAttributes, HTMLTableSetting); return(htmltablegenerater.ToHtmlTableByDataTable(datatable)); }
public static string ToHtmlTable <T>(this IEnumerable <T> enums, object tableAttributes = null, object tbAttributes = null, object trAttributes = null, object tdAttributes = null, object thAttributes = null, HtmlTableSetting HTMLTableSetting = null) { return(ToHtmlTableByIEnumrable(enums, tableAttributes, tbAttributes, trAttributes, tdAttributes, thAttributes, HTMLTableSetting)); }
public static string ToHtmlTable(this HtmlTableHelperBuilder builder, object tableAttributes = null, object tbAttributes = null, object trAttributes = null, object tdAttributes = null, object thAttributes = null, HtmlTableSetting HTMLTableSetting = null) { return(ToHtmlTableByIEnumrable(builder.Enums, tableAttributes, tbAttributes, trAttributes, tdAttributes, thAttributes, HTMLTableSetting, builder)); }
public static HtmlTableGenerater CreateInstance <T1, T2, T3, T4, T5>(T1 tableAttributes, T2 trAttributes, T3 tdAttributes, T4 thAttributes, T5 tbAttributes, HtmlTableSetting htmlTableSetting) { var htmltablegenerater = new HtmlTableGenerater { _HtmlTableSetting = htmlTableSetting ?? _DefualtHTMLTableSetting, _TableAttributes = AttributeToHtml(tableAttributes), _TrAttributes = AttributeToHtml(trAttributes), _TdAttributes = AttributeToHtml(tdAttributes), _ThAttributes = AttributeToHtml(thAttributes), _TbAttributes = AttributeToHtml(tbAttributes), }; htmltablegenerater.RenderTableTrTdAttributehtml(); return(htmltablegenerater); }