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
allYearsHtmlBoxesIList<string>List of HTML boxes for each month (must have 12 items).
allMonthsBoxColorsIList<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
yearsIList<string>List of year labels.
allYearsHtmlBoxesIList<string>List of HTML boxes for each year.
allYearsBoxColorsIList<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
urlstringThe URL (without http://).
Returns
- string
HTML anchor string.
AnchorMailto(string)
Creates a mailto anchor link.
public static string AnchorMailto(string email)
Parameters
emailstringThe 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
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
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
urlstringThe 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
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
isTargetBlankboolWhether to open in new tab.
textstringThe link text.
httpUrlstringThe HTTP URL.
Returns
- string
HTML anchor string.
Bold(string)
Wraps text in bold tags.
public static string Bold(string text)
Parameters
textstringThe 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
htmlGeneratorHtmlGeneratorThe HTML generator.
textstringButton text.
attributeNamestringAttribute name.
attributeValuestringAttribute 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
htmlBoxesEveryDayIList<string>List of HTML content for each day.
colorsIList<string>List of background colors for each day.
yearintThe year.
monthintThe 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
htmlBoxesEveryDayIList<string>List of HTML content for each day.
yearintThe year.
monthintThe month (1-12).
Returns
- string
HTML string representing the calendar.
CheckBox(string)
Generates a checkbox with label.
public static string CheckBox(string data)
Parameters
datastringThe 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
DetailIfNotEmpty(string, string)
Writes a detail line with name and value if value is not empty.
public void DetailIfNotEmpty(string name, string value)
Parameters
DetailStatic(string, object)
Returns a static detail line with name and value.
public static string DetailStatic(string name, object value)
Parameters
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
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
memberNamesIList<string>List of member names.
memberProfilePicturesIList<string>List of profile picture URLs.
memberAnchorsIList<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
pathstringThe directory path.
searchPatternstringThe search pattern for files.
searchOptionSearchOptionThe 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
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
idClassCheckboxstringID class for checkboxes.
idClassSpanstringID class for spans.
idCheckBoxesIList<string>List of checkbox IDs.
listIList<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
baseAnchorstringBase anchor URL.
idsIList<string>List of IDs.
textsIList<string>List of display texts.
isSkipDuplicatesboolWhether 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
baseAnchorstringBase anchor URL.
idsstring[]Array of IDs.
textsstring[]Array of display texts.
isSkipDuplicatesboolWhether 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
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
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
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
baseAnchorstringBase anchor URL (e.g. "EditMister.aspx?mid=").
itemsIList<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
baseAnchorstringBase anchor URL.
idsIList<string>List of IDs for anchors.
textsIList<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
baseAnchorstringBase anchor URL.
idsIList<string>List of IDs for anchors.
findInTextstringText to find in display text.
replaceInTextstringText to replace with.
suffixstringOptional 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
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
possibleAnswersIList<string>List of possible answers.
isCheckDuplicatesboolWhether 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
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
namestringThe name attribute for radio buttons.
idsIList<string>List of radio button IDs/values.
labelsIList<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
namestringThe name attribute for radio buttons.
idsIList<string>List of radio button IDs/values.
labelsIList<string>List of radio button labels.
eventHandlerSelectedstringThe 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
idstringThe ID for the select element.
defaultValueobjectThe default selected value.
listIListThe 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
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
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
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
wordCountDictionary<string, short>Dictionary of words and their counts.
cssSelectorstringCSS 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
wordCountDictionary<string, short>Dictionary of words and their counts.
cssSelectorstringCSS 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
actionAction<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
textstringThe 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
textstringThe 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
Returns
- string
HTML string with shortened text and tooltip.
Success(string)
Generates a success message div.
public static string Success(string message)
Parameters
messagestringThe 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
htmlGeneratorHtmlGeneratorThe HTML generator to use.
widthImageintImage width in pixels.
heightImageintImage height in pixels.
initialImageUristringInitial image URI.
photoLinksIList<string>List of photo link URLs.
textLinksIList<string>List of text link URLs.
innerHtmlTextIList<string>List of inner HTML text.
srcPhotoIList<string>List of photo source paths.
idBadgesIList<string>List of badge IDs.
arrayNamestringJavaScript 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
htmlGeneratorHtmlGeneratorThe HTML generator to use.
widthImageintImage width in pixels.
heightImageintImage height in pixels.
initialImageUristringInitial image URI.
photoLinksIList<string>List of photo link URLs.
textLinksIList<string>List of text link URLs.
innerHtmlTextIList<string>List of inner HTML text.
srcPhotoIList<string>List of photo source paths.
arrayNamestringJavaScript array name.
Returns
- string
HTML string representing the list with images.