Question

How can I handle an ampersand ("&") character in a Telerik HTML textbox? While rendering, it's giving me an error. Also, does anybody know about any other character that may cause errors in an HTML textbox?

Was it helpful?

Solution

Ampersand is a special character in HTML that specifies the start of an escape sequence (so you can do something like © to get a copyright symbol, etc.). If you want to display an ampersand you have to escape it. So if you replace all ampersands with &, that should take care of the error.

However, if there were ampersands in your input that were already escaped - like maybe your data had © - you wouldn't want to escape that ampersand. But if your data won't have any of these ampersands, a simple replace should be fine.

You also need to replace greater than and less than symbols (> and <) with &gt; and &lt; respectively.

Telerik talks about these limitations/issues on this page http://www.telerik.com/help/reporting/report-items-html-text-box.html

Also according to the HTML specification (and the general XML specification as well) the "&", "<" and ">" characters are considered special (markup delimiters), so they need to be encoded in order to be treated as regular text. For example the "&" character can be escaped with the "&" entity. More information on the subject you can find in this w3.org article.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top