LearnFast.Ninja

Create ul list with bullet summary points function

With this function we get as parameters the summary text and create bullets with the summary. We did some padding to left because we did not want the list to be right from the text. Also we building the Html with StringBuilder and then return the Html. In case all the Summary in empty or NULL we will return No Summary.

The function code:

public static string Create_Summary_ul_List(string Summary1, string Summary2, string Summary3)

{

    string Html;

 

    if (!string.IsNullOrEmpty(Summary1))

    {

        StringBuilder oStringBuilder = new StringBuilder();

        oStringBuilder.Append("<ul style='padding-left: 17px;'>");

        oStringBuilder.Append("<li>");

        oStringBuilder.Append(Summary1);

        oStringBuilder.Append("</li>");

        if (!string.IsNullOrEmpty(Summary2))

        {

            oStringBuilder.Append("<li>");

            oStringBuilder.Append(Summary2);

            oStringBuilder.Append("</li>");

        }

        if (!string.IsNullOrEmpty(Summary3))

        {

            oStringBuilder.Append("<li>");

            oStringBuilder.Append(Summary3);

            oStringBuilder.Append("</li>");

        }

        oStringBuilder.Append("</ul>");

        Html = oStringBuilder.ToString();

    }

    else

    {

        Html = "No Summary";

    }

    return Html;

}


How to use the function:

Summary_1 = "Summary 1";

Summary_2 = "Summary 2";

Summary_3 = "Summary 3";

Summary = HelpFunctions.Create_Summary_ul_List(Summary_1, Summary_2, Summary_3);


Result:


Tags

asp.net

helpfunctions help-functions functions ul li stringbuilder summary