Table of Contents

Class HtmlGenerator2

Namespace
SunamoHtml.Generators
Assembly
SunamoHtml.dll

Extended HTML generator with calendar, gallery, and form generation methods.

public class HtmlGenerator2 : HtmlGenerator
Inheritance
HtmlGenerator2
Inherited Members
Extension Methods

Methods

AllMonthsTable(IList<string>, IList<string>)

Generates a table for all months of the year with colored boxes.

public static string AllMonthsTable(IList<string> allYearsHtmlBoxes, IList<string> allMonthsBoxColors)

Parameters

allYearsHtmlBoxes IList<string>

List of HTML boxes for each month (must have 12 items).

allMonthsBoxColors IList<string>

List of colors for each month box (must have 12 items).

Returns

string

HTML string with months table.

AllYearsTable(IList<string>, IList<string>, IList<string>)

Generates a table for all years with colored boxes.

public static string AllYearsTable(IList<string> years, IList<string> allYearsHtmlBoxes, IList<string> allYearsBoxColors)

Parameters

years IList<string>

List of year labels.

allYearsHtmlBoxes IList<string>

List of HTML boxes for each year.

allYearsBoxColors IList<string>

List of colors for each year box.

Returns

string

HTML string with years table.

Anchor(string)

Creates an anchor link, automatically adding http:// if not present. Provide URL without https://, it will be added to the link automatically, but not to the text.

[SuppressMessage("Design", "CA1054", Justification = "url is used as a raw HTML attribute value, not as a System.Uri")]
public static string Anchor(string url)

Parameters

url string

The URL (without http://).

Returns

string

HTML anchor string.

AnchorMailto(string)

Creates a mailto anchor link.

public static string AnchorMailto(string email)

Parameters

email string

The email address.

Returns

string

HTML mailto anchor string.

AnchorWithCustomLabel(string, string)

Creates an anchor with custom label.

[SuppressMessage("Design", "CA1054", Justification = "uri is used as a raw HTML attribute value, not as a System.Uri")]
public static string AnchorWithCustomLabel(string uri, string text)

Parameters

uri string

The URI.

text string

The link text.

Returns

string

HTML anchor string.

AnchorWithHttp(bool, string, string)

Creates an anchor with HTTP protocol and optional target blank.

[SuppressMessage("Design", "CA1054", Justification = "url is used as a raw HTML attribute value, not as a System.Uri")]
public static string AnchorWithHttp(bool isTargetBlank, string url, string text)

Parameters

isTargetBlank bool

Whether to open in new tab.

url string

The URL.

text string

The link text.

Returns

string

HTML anchor string.

AnchorWithHttp(string)

Creates an anchor with HTTP protocol. URL without http:// / https:// will have it added to the link. The text will always have http:// removed if present.

[SuppressMessage("Design", "CA1054", Justification = "url is used as a raw HTML attribute value, not as a System.Uri")]
public static string AnchorWithHttp(string url)

Parameters

url string

The URL.

Returns

string

HTML anchor string.

AnchorWithHttp(string, string)

Creates an anchor with HTTP protocol and custom text.

[SuppressMessage("Design", "CA1054", Justification = "url is used as a raw HTML attribute value, not as a System.Uri")]
public static string AnchorWithHttp(string url, string text)

Parameters

url string

The URL.

text string

The link text.

Returns

string

HTML anchor string.

AnchorWithHttpCore(bool, string, string)

Core method for creating anchors with HTTP protocol.

[SuppressMessage("Design", "CA1054", Justification = "httpUrl is used as a raw HTML attribute value, not as a System.Uri")]
public static string AnchorWithHttpCore(bool isTargetBlank, string text, string httpUrl)

Parameters

isTargetBlank bool

Whether to open in new tab.

text string

The link text.

httpUrl string

The HTTP URL.

Returns

string

HTML anchor string.

Bold(string)

Wraps text in bold tags.

public static string Bold(string text)

Parameters

text string

The text to wrap.

Returns

string

HTML string with bold tags.

ButtonDelete(HtmlGenerator, string, string, string)

Generates a delete button with icon.

public static void ButtonDelete(HtmlGenerator htmlGenerator, string text, string attributeName, string attributeValue)

Parameters

htmlGenerator HtmlGenerator

The HTML generator.

text string

Button text.

attributeName string

Attribute name.

attributeValue string

Attribute value.

Calendar(IList<string>, IList<string>, int, int)

Generates a calendar with colored boxes for each day.

public static string Calendar(IList<string> htmlBoxesEveryDay, IList<string> colors, int year, int month)

Parameters

htmlBoxesEveryDay IList<string>

List of HTML content for each day.

colors IList<string>

List of background colors for each day.

year int

The year.

month int

The month (1-12).

Returns

string

HTML string representing the calendar.

Calendar(IList<string>, int, int)

Generates a calendar for the specified year and month with HTML boxes for each day.

public static string Calendar(IList<string> htmlBoxesEveryDay, int year, int month)

Parameters

htmlBoxesEveryDay IList<string>

List of HTML content for each day.

year int

The year.

month int

The month (1-12).

Returns

string

HTML string representing the calendar.

CheckBox(string)

Generates a checkbox with label.

public static string CheckBox(string data)

Parameters

data string

The checkbox label.

Returns

string

HTML string with checkbox.

Detail(string, object)

Writes a detail line with name and value.

public void Detail(string name, object value)

Parameters

name string

The detail name.

value object

The detail value.

DetailIfNotEmpty(string, string)

Writes a detail line with name and value if value is not empty.

public void DetailIfNotEmpty(string name, string value)

Parameters

name string

The detail name.

value string

The detail value.

DetailStatic(string, object)

Returns a static detail line with name and value.

public static string DetailStatic(string name, object value)

Parameters

name string

The detail name.

value object

The detail value.

Returns

string

HTML string with detail.

DetailStatic(string, string, object)

Returns a static detail line with custom color.

public static string DetailStatic(string color, string name, object value)

Parameters

color string

The text color.

name string

The detail name.

value object

The detail value.

Returns

string

HTML string with colored detail.

GalleryZoomInProfilePhoto(IList<string>, IList<string>, IList<string>)

Generates a photo gallery with zoom functionality.

public static string GalleryZoomInProfilePhoto(IList<string> memberNames, IList<string> memberProfilePictures, IList<string> memberAnchors)

Parameters

memberNames IList<string>

List of member names.

memberProfilePictures IList<string>

List of profile picture URLs.

memberAnchors IList<string>

List of anchor URLs.

Returns

string

HTML string representing the gallery.

GenerateHtmlCheckBoxesFromFiles(string, string, SearchOption)

Generates HTML checkboxes from files in the specified directory.

public static string GenerateHtmlCheckBoxesFromFiles(string path, string searchPattern, SearchOption searchOption)

Parameters

path string

The directory path.

searchPattern string

The search pattern for files.

searchOption SearchOption

The search option.

Returns

string

HTML string with checkboxes.

GenerateTreeWithCheckBoxes(NTreeHtml<string>)

Generates a tree structure with checkboxes.

public static string GenerateTreeWithCheckBoxes(NTreeHtml<string> tree)

Parameters

tree NTreeHtml<string>

The tree structure to generate.

Returns

string

HTML string with tree and checkboxes.

GetForCheckBoxListWoCheckDuplicate(string, string, IList<string>, IList<string>)

Generates checkbox list without duplicate checking.

public static string GetForCheckBoxListWoCheckDuplicate(string idClassCheckbox, string idClassSpan, IList<string> idCheckBoxes, IList<string> list)

Parameters

idClassCheckbox string

ID class for checkboxes.

idClassSpan string

ID class for spans.

idCheckBoxes IList<string>

List of checkbox IDs.

list IList<string>

List of checkbox labels.

Returns

string

HTML string with checkbox list.

GetForUl(string, IList<string>, IList<string>, bool)

Generates list items for UL (list version).

public static string GetForUl(string baseAnchor, IList<string> ids, IList<string> texts, bool isSkipDuplicates)

Parameters

baseAnchor string

Base anchor URL.

ids IList<string>

List of IDs.

texts IList<string>

List of display texts.

isSkipDuplicates bool

Whether to skip duplicate texts.

Returns

string

HTML string with list items.

GetForUl(string, string[], string[], bool)

Generates list items for UL (array version).

public static string GetForUl(string baseAnchor, string[] ids, string[] texts, bool isSkipDuplicates)

Parameters

baseAnchor string

Base anchor URL.

ids string[]

Array of IDs.

texts string[]

Array of display texts.

isSkipDuplicates bool

Whether to skip duplicate texts.

Returns

string

HTML string with list items.

GetForUlWCheckDuplicate(IList<string>)

Generates list items for UL with duplicate checking.

public static string GetForUlWCheckDuplicate(IList<string> items)

Parameters

items IList<string>

List of items to generate.

Returns

string

HTML string with list items.

GetForUlWoCheckDuplicate(IList<string>)

Generates list items for UL without anchors. This method is used when you don't use any links in UL.

public static string GetForUlWoCheckDuplicate(IList<string> items)

Parameters

items IList<string>

List of items to display.

Returns

string

HTML string with list items.

GetForUlWoCheckDuplicate(IList<string>, IList<string>)

Generates list items for UL without duplicate checking. Counts in both parameters must be equal.

public static string GetForUlWoCheckDuplicate(IList<string> anchors, IList<string> items)

Parameters

anchors IList<string>

List of anchor URLs.

items IList<string>

List of display texts.

Returns

string

HTML string with list items.

GetForUlWoCheckDuplicate(string, IList<string>)

Generates list items for UL without duplicate checking. When URI args and titles are the same.

public static string GetForUlWoCheckDuplicate(string baseAnchor, IList<string> items)

Parameters

baseAnchor string

Base anchor URL (e.g. "EditMister.aspx?mid=").

items IList<string>

List of items (used as both IDs and display text).

Returns

string

HTML string with list items.

GetForUlWoCheckDuplicate(string, IList<string>, IList<string>)

Generates list items for UL without duplicate checking.

public static string GetForUlWoCheckDuplicate(string baseAnchor, IList<string> ids, IList<string> texts)

Parameters

baseAnchor string

Base anchor URL.

ids IList<string>

List of IDs for anchors.

texts IList<string>

List of display texts.

Returns

string

HTML string with list items.

GetForUlWoCheckDuplicate(string, IList<string>, string, string, string)

Generates list items for UL with text replacement.

public static string GetForUlWoCheckDuplicate(string baseAnchor, IList<string> ids, string findInText, string replaceInText, string suffix = "")

Parameters

baseAnchor string

Base anchor URL.

ids IList<string>

List of IDs for anchors.

findInText string

Text to find in display text.

replaceInText string

Text to replace with.

suffix string

Optional suffix to append to anchors.

Returns

string

HTML string with list items.

GetInputText(string, string)

Generates an HTML text input element.

public static string GetInputText(string id, string value)

Parameters

id string

The ID for the input element.

value string

The initial value.

Returns

string

HTML string representing the input element.

GetOl(IList<string>, bool)

Generates an OL (ordered list) element.

public static string GetOl(IList<string> possibleAnswers, bool isCheckDuplicates = false)

Parameters

possibleAnswers IList<string>

List of possible answers.

isCheckDuplicates bool

Whether to check for duplicates.

Returns

string

HTML string with OL element.

GetOlWoCheckDuplicate(IList<string>, IList<string>)

Generates OL element without duplicate checking.

public static string GetOlWoCheckDuplicate(IList<string> anchors, IList<string> texts)

Parameters

anchors IList<string>

List of anchor URLs.

texts IList<string>

List of items to display.

Returns

string

HTML string with OL element.

GetRadioButtonsWoCheckDuplicate(string, IList<string>, IList<string>)

Generates radio buttons without duplicate checking.

public static string GetRadioButtonsWoCheckDuplicate(string name, IList<string> ids, IList<string> labels)

Parameters

name string

The name attribute for radio buttons.

ids IList<string>

List of radio button IDs/values.

labels IList<string>

List of radio button labels.

Returns

string

HTML string with radio buttons.

GetRadioButtonsWoCheckDuplicate(string, IList<string>, IList<string>, string)

Generates radio buttons with click event handler.

public static string GetRadioButtonsWoCheckDuplicate(string name, IList<string> ids, IList<string> labels, string eventHandlerSelected)

Parameters

name string

The name attribute for radio buttons.

ids IList<string>

List of radio button IDs/values.

labels IList<string>

List of radio button labels.

eventHandlerSelected string

The onclick event handler.

Returns

string

HTML string with radio buttons.

GetSelect(string, object, IList)

Generates an HTML select element with options.

public static string GetSelect(string id, object defaultValue, IList list)

Parameters

id string

The ID for the select element.

defaultValue object

The default selected value.

list IList

The list of options.

Returns

string

HTML string representing the select element.

GetUlWoCheckDuplicate(IList<string>, IList<string>)

Generates complete UL element with anchors and texts.

public static string GetUlWoCheckDuplicate(IList<string> anchors, IList<string> texts)

Parameters

anchors IList<string>

List of anchor URLs.

texts IList<string>

List of display texts.

Returns

string

HTML string with UL element.

GetUlWoCheckDuplicate(IList<string>, string)

Generates complete UL element with list items and custom class. Takes only one parameter, so it's without links.

public static string GetUlWoCheckDuplicate(IList<string> list, string appendClass)

Parameters

list IList<string>

List of items.

appendClass string

Additional CSS class to append.

Returns

string

HTML string with UL element.

GetUlWoCheckDuplicate(string, IList<string>)

Generates complete UL element with list items.

public static string GetUlWoCheckDuplicate(string baseAnchor, IList<string> items)

Parameters

baseAnchor string

Base anchor URL.

items IList<string>

List of items.

Returns

string

HTML string with UL element.

GetWordsForTagCloud(Dictionary<string, short>, string)

Generates tag cloud HTML for jquery.tagcloud.js.

public static string GetWordsForTagCloud(Dictionary<string, short> wordCount, string cssSelector)

Parameters

wordCount Dictionary<string, short>

Dictionary of words and their counts.

cssSelector string

CSS selector prefix for JavaScript method.

Returns

string

HTML string for tag cloud.

GetWordsForTagCloudManageTags(Dictionary<string, short>, string)

Generates tag cloud HTML for manage tags page.

public static string GetWordsForTagCloudManageTags(Dictionary<string, short> wordCount, string cssSelector)

Parameters

wordCount Dictionary<string, short>

Dictionary of words and their counts.

cssSelector string

CSS selector prefix for JavaScript method.

Returns

string

HTML string for tag cloud.

HtmlGeneratorToString(Action<HtmlGenerator>)

Executes HTML generator action and returns the generated string.

public static string HtmlGeneratorToString(Action<HtmlGenerator> action)

Parameters

action Action<HtmlGenerator>

The action to execute with the generator.

Returns

string

Generated HTML string.

Italic(string)

Wraps text in italic tags.

public static string Italic(string text)

Parameters

text string

The text to wrap.

Returns

string

HTML string with italic tags.

LiI(string)

Wraps text in li and i tags.

public static string LiI(string text)

Parameters

text string

The text to wrap.

Returns

string

HTML string with li>i tags.

ShortForLettersCount(string, int)

Shortens text to specified letter count with ellipsis tooltip.

public static string ShortForLettersCount(string text, int maxLength)

Parameters

text string

The text to shorten.

maxLength int

Maximum length in characters.

Returns

string

HTML string with shortened text and tooltip.

Success(string)

Generates a success message div.

public static string Success(string message)

Parameters

message string

The success message.

Returns

string

HTML string with success div.

TopListWithImages(HtmlGenerator, int, int, string, IList<string>, IList<string>, IList<string>, IList<string>, IList<string>, string)

Generates a top list with images and badges (divs stacked vertically, not ol/ul>li).

[SuppressMessage("Design", "CA1054", Justification = "initialImageUri is used as a raw HTML attribute value, not as a System.Uri")]
public static string TopListWithImages(HtmlGenerator htmlGenerator, int widthImage, int heightImage, string initialImageUri, IList<string> photoLinks, IList<string> textLinks, IList<string> innerHtmlText, IList<string> srcPhoto, IList<string> idBadges, string arrayName)

Parameters

htmlGenerator HtmlGenerator

The HTML generator to use.

widthImage int

Image width in pixels.

heightImage int

Image height in pixels.

initialImageUri string

Initial image URI.

photoLinks IList<string>

List of photo link URLs.

textLinks IList<string>

List of text link URLs.

innerHtmlText IList<string>

List of inner HTML text.

srcPhoto IList<string>

List of photo source paths.

idBadges IList<string>

List of badge IDs.

arrayName string

JavaScript array name.

Returns

string

HTML string representing the list with images and badges.

TopListWithImages(HtmlGenerator, int, int, string, IList<string>, IList<string>, IList<string>, IList<string>, string)

Generates a top list with images (divs stacked vertically, not ol/ul>li).

[SuppressMessage("Design", "CA1054")]
public static string TopListWithImages(HtmlGenerator htmlGenerator, int widthImage, int heightImage, string initialImageUri, IList<string> photoLinks, IList<string> textLinks, IList<string> innerHtmlText, IList<string> srcPhoto, string arrayName)

Parameters

htmlGenerator HtmlGenerator

The HTML generator to use.

widthImage int

Image width in pixels.

heightImage int

Image height in pixels.

initialImageUri string

Initial image URI.

photoLinks IList<string>

List of photo link URLs.

textLinks IList<string>

List of text link URLs.

innerHtmlText IList<string>

List of inner HTML text.

srcPhoto IList<string>

List of photo source paths.

arrayName string

JavaScript array name.

Returns

string

HTML string representing the list with images.