问题
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 &
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