asp.net 中的 w3c 验证错误

发布于 2024-12-23 17:45:18 字数 443 浏览 2 评论 0原文

我是 W3c 验证的新手,我正在尝试修复此错误,但它没有发生。错误如下:

字符“&”是分隔符的第一个字符,但作为数据出现。

我正在使用 DataList Control 绑定数据,这是发生 w3c 验证错误的行。

<asp:Label ID="lblDescription"  
           runat="server" 
           Text='<%#Eval("Decr") %>'>
</asp:Label>

在数据库中,存储了Decr,并且在描述字段中也给出了这个(&)特殊字符。 w3c 未验证此行。

I am new in W3c validations, I am trying to fix this error but it's not happening. The error is following:

character "&" is the first character of a delimiter but occurred as data.

I am using DataList Control to bind data and here is the line where the w3c validation error occurs.

<asp:Label ID="lblDescription"  
           runat="server" 
           Text='<%#Eval("Decr") %>'>
</asp:Label>

In database, the Decr is stored and this(&) special character is also given in the description field. w3c is not validating this line.

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

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

发布评论

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

评论(2

七七 2024-12-30 17:45:18

& 是 concat 的特殊字符,需要对其进行转义:全部设为 & 而不是 &。

& is a special charater for concat, you need to escape it: make them all & not &.

初吻给了烟 2024-12-30 17:45:18

这是我想出的解决方案:

<asp:Label ID="lblDescription" runat="server" Text='<%# Server.HtmlEncode( (string) Eval("Decr")) %>'></asp:Label>

Here is the solution I came up with:

<asp:Label ID="lblDescription" runat="server" Text='<%# Server.HtmlEncode( (string) Eval("Decr")) %>'></asp:Label>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文