Bug 13592 - HTML in ListItem is rendered as text
Summary: HTML in ListItem is rendered as text
Status: NEW
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web (show other bugs)
Version: unspecified
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2013-07-30 04:29 UTC by APS
Modified: 2013-07-30 04:33 UTC (History)
1 user (show)

See Also:
Is this bug a regression?: ---
Last known good build:


Description APS 2013-07-30 04:29:18 UTC

Creating a dropdownlist with a ListItem like this:

<asp:ListItem Value="3" Text="">&nbsp;</asp:ListItem>

Mono 2.0 renders:
<option selected="selected" value="3">&#160;</option>
Mono 3.0.7 renders:
<option selected="selected" value="3">&amp;nbsp;</option>
MS ASP.NET 4.0 renders:
<option selected="selected" value="3"></option>

The Mono 3.0.7 version is the worst because it displays "&nbsp;" to the end user. According to documentation http://msdn.microsoft.com/it-it/library/system.web.ui.webcontrols.listitem.aspx the correct result should be:
<option selected="selected" value="3">&nbsp;</option>
Comment 1 APS 2013-07-30 04:33:53 UTC
Forgot to say that I fixed the problem on my installation but I can't say if it's correct.
I modified mcs/class/System.Web/System.Web.UI.WebControls/ListControl.cs removing HtmlEncode on text when it's written in the inner html:

Line 380 from:

   string encoded = HttpUtility.HtmlEncode (item.Text);
   writer.Write (encoded);
   writer.WriteEndTag ("option");


   //string encoded = HttpUtility.HtmlEncode (item.Text);
   writer.Write (item.Text);
   writer.WriteEndTag ("option");

Note You need to log in before you can comment on or make changes to this bug.