w3c validation error in asp.net

≡放荡痞女 提交于 2019-12-02 07:09:23

问题


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.


回答1:


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




回答2:


Here is the solution I came up with:

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


来源:https://stackoverflow.com/questions/8689804/w3c-validation-error-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!