Stop ASP.NET web control from HTML encoding output > Specifically, list items in a bulleted list

[亡魂溺海] 提交于 2019-12-11 06:33:12

问题


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.

来源:https://stackoverflow.com/questions/14511463/stop-asp-net-web-control-from-html-encoding-output-specifically-list-items-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!