2

I have an ASP.NET bulleted list control that is html encoding the list items.

<strong>First Name</strong> is required and must consist of letters only.

Is not resulting in "First Name" being output in bold text.

How do I stop the bulleted list control from html encoding its list item output?

The line in the web form is: <asp:BulletedList ID="bltUserDetailsErrors" runat="server"></asp:BulletedList>

Then there's an intermediate list of error messages:

userDetailsMessageList.Add(
                "<strong>First Name</strong>is required, must contain only letters, " +
                "and be no more than 50 letters.");

Which are then added to the bulleted list:

bltUserDetailsErrors.Items.Clear();
            foreach (string message in userDetailsMessageList)
            {
                bltUserDetailsErrors.Items.Add(new ListItem(message));
            }

Yes, it's definitely html encoding the output.

<li>&lt;strong&gt;First Name&lt;/strong&gt;is required, must contain only letters, and be no more than 50 letters.</li>

How do you get the bulleted list to render the <strong></strong> tags so that the text is bolded in the browser.

5
  • What? Can you post an image and how your code is being generated? Commented Jan 24, 2013 at 21:52
  • msdn.microsoft.com/en-us/library/… Commented Jan 24, 2013 at 21:53
  • "Is not resulting in "First Name" being output in bold text" But it does, First Name is bold, the rest not. Commented Jan 24, 2013 at 21:59
  • So are you getting the text "<strong>First Name</strong>" in your bulleted list? Or or "First Name" but not bolded? The first would be the result of HTML encoding, the second may be a style problem. Commented Jan 24, 2013 at 22:56
  • 1
    You can use a repeater as a workaround. stackoverflow.com/questions/2813746/… Commented Jan 25, 2013 at 3:03

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.