问题
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><strong>First Name</strong>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.
来源:https://stackoverflow.com/questions/14511463/stop-asp-net-web-control-from-html-encoding-output-specifically-list-items-in