0

I have a basic asp repeater that generates a ul and its child lis. It seems that each li is preceded by this magical zero space character (​). This messes up the design by adding extra space between each list item.

The code is currently on a dev site so I can't give you a link. Here is the basic markup

<asp:Repeater ID="rptrPageMeta" runat="server">
<HeaderTemplate>
    <ul>
</HeaderTemplate>
<ItemTemplate>​
    <li>
    </li>
</ItemTemplate>
<FooterTemplate>
    </ul>
    <div class="clear"></div>
</FooterTemplate>
</asp:Repeater>

The repeater has a list of data items that gets bound to it in the Presenter. But in this example it is irrelevant since nothing from each item gets rendered. This is what it generates:

<ul>
&#8203;
    <li>
    </li>&#8203;
    <li>
    </li>&#8203;
    <li>
    </li>&#8203;
    <li>
    </li>&#8203;
    <li>
    </li>&#8203;
    <li>
    </li>
</ul>

I would like to remove the character rather than do a CSS hack to hide it. I have tried to remove all white space from the file by making all the code on one line. This removed the white spaces that were there but wont get rid of the zero space character. I also edited the file in notepad++ with all characters displayed and the character wasn't there.

What are some ways that I can remove this character?

EDIT: I did create a fresh project and was not able to reproduce this issue. The only thing I can assume now is that it is caused by Sitefinity. This code is used in a widget template inside of a Sitefinity 5 CMS.

Current Hack: The way I am getting around this is by using the following js on the specific list:

if ($('.my-list').length > 0) {
    $('.my-list').each(function() {
        $(this).html($(this).children('li'));
    });
}
Community
  • 1
  • 1
bygrace
  • 5,868
  • 1
  • 31
  • 58

2 Answers2

1

In the ItemTemplate, have the tags be beside each other.

<ItemTemplate​><li></li><ItemTemplate>

mccrager
  • 1,038
  • 6
  • 13
1

You are starting from the incorrect assumption that the Repeater control is emitting this character. It is not. Either your data or your source code contains the char.

Of course, you can't see that char in Visual Studio because it is zero-width after all. Try using Notepad++ and configure it to show even special characters. Alternatively use a hex-editor.

usr
  • 168,620
  • 35
  • 240
  • 369
  • The data being bound to the repeater doesn't affect the output since the item template is
  • . I had already opened my file in notepad and notepad++ with all characters displayed and the character is not there. – bygrace Jun 04 '12 at 15:01