Tracy Gough Tracy Gough - 3 months ago 16
ASP.NET (C#) Question

Entity Framework BindItem renders HTML escape instead of apostophe

I am using the Entity Framework to maintain data for ASP.net 4.5 application. Any data that has an apostrophe (single quote) in the data is rendered in the web form's textbox as HTML escape

'
. I have verified the data is stored as expected in the database correctly. For example: I store the value
PETE'S GARAGE
in the database but when I want to edit the data the textbox is populated with
PETE'S GARAGE
. The code I have in the web form to populate the textbox vlaue is this:

Text="<%#:BindItem.BusinessName%>"


How can I make this render the data correctly without the HTML escape?

Answer

I found the answer to this. The syntax <%#: actually implicitly forces HTML encoding due to the colon :. I removed the colon and it works as expected.

Comments