1

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.

Mat
  • 202,337
  • 40
  • 393
  • 406
Sam
  • 243
  • 2
  • 5
  • 18

2 Answers2

1

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

Ura
  • 2,173
  • 3
  • 24
  • 41
  • In Database it stored as '&' , so i want to correct the validation.. is there any way to use CDATA in this code during data binding?? – Sam Dec 31 '11 at 18:43
1

Here is the solution I came up with:

<asp:Label ID="lblDescription" runat="server" Text='<%# Server.HtmlEncode( (string) Eval("Decr")) %>'></asp:Label>
Purag
  • 16,941
  • 4
  • 54
  • 75
Sam
  • 243
  • 2
  • 5
  • 18