ASP.NET DataBoundField DataFormatString,如何正确添加html?

发布于 2024-09-28 08:07:07 字数 435 浏览 0 评论 0原文

我在网格中有一个 DataboundField。我正在尝试以欧元格式显示日期和时间。时间应该包含在一个跨度中,并应用了 css 类。

我正在使用这个, DataFormatString="{0:dd/MM/yyyy <\span cla\s\s='tinyDate'>hh:mm:ss}"

它实际上非常接近,除了 span 标签实际上是在浏览器中呈现的。

在单元格中,文本看起来像这样

19/10/2010 <span class=tinyDate>09:35:00</span>

我不打算看到跨度标签,只有它的格式化内容。我该如何解决这个问题并使其正确渲染?

感谢您提供任何提示或链接。

干杯,
〜ck在圣地亚哥

I have a DataboundField in a grid. I'm trying to display a date in Euro format and the time. The time should be wrapped in a span with a css class applied to it.

I am using this, DataFormatString="{0:dd/MM/yyyy <\span cla\s\s='tinyDate'>hh:mm:ss</\span>}"

It's actually pretty close, except the span tag is literally rendering in the browser.

In the cell the text looks like this

19/10/2010 <span class=tinyDate>09:35:00</span>

I don't intend to see the span tag, only it's formatted content. How can I remedy this and make it render correctly?

Thanks for any tips or links.

Cheers,
~ck in San Diego

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魂归处 2024-10-05 08:07:07

尝试将字段的 HtmlEncode 属性设置为“false”。默认情况下启用它以防止执行任何恶意客户端脚本代码。

Try setting the HtmlEncode property of the field to "false". It's enabled by default to prevent any malicious client-script code from being executed.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文