Вложенные элементы span, где parent находится на стороне сервера
В ASP.Net (4.5.2) я вложил <span>
элементы, где родительский элемент установлен как элемент управления на стороне сервера...
<p>
This is the start of the text
<span runat="server" visible="<%#someCode%>">
This is some more Text
<span class="myClass">with some other text inside</span>
And a bit more after
</span>
</p>
(Обратите внимание, это содержится в <asp:Repeater>
)
Похоже, что ASP.Net не справляется с этим, и, кажется, предполагает внутренний </span>
это закрытие для внешнего элемента. Это означает, что когда visible="false"
это будет выглядеть так...
<p>
This is the start of the text
And a bit more after
</span>
</p>
Я не могу конвертировать либо <span>
в <div>
или же <section>
как это должно жить в <p>
element (то есть дочерние элементы не могут быть блоками).
Есть ли способ обойти эту проблему?
2 ответа
Хорошо, тогда (слишком много комментариев).
В качестве альтернативы используйте Label
:
<p>
This is the start of the text
<asp:Label ID="Label1" runat="server" Visible="false" Text="This is some more Text">
<span class="myClass">with some other text inside</span>
And a bit more after
</asp:Label>
</p>
или даже:
<p>
This is the start of the text
<asp:Label ID="Label1" runat="server" Visible="true" Text="This is some more Text<span class='myClass'>with some other text inside</span>And a bit more after">
</asp:Label>
</p>
Оказывается, ответ довольно прост... сделать внутренний <span>
серверный контроль, а также...
<p>
This is the start of the text
<span runat="server" visible="<%#someCode%>">
This is some more Text
<span runat="server" class="myClass">with some other text inside</span>
And a bit more after
</span>
</p>
Что приводит к...
<p>
This is the start of the text
</p>