Question

I create many ListItem dynamically for a DropDownList ASP.net control, and need some of this ListItem's Text Property, have two or three "Space". I try this:

var li = new ListItem { Text = "   " + "Item" };

but in HTML rendered page, it's text appears ==> '   Item'

What should I do?

Was it helpful?

Solution

Try to decode the space characters first...

li.Text = HttpUtility.HtmlDecode("   ") + "Item";
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top