This is a migrated thread and some comments may be shown as answers.

Display special chars in HTML Textbox

4 Answers 839 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Hung
Top achievements
Rank 1
Hung asked on 14 Apr 2021, 09:04 AM

Hi everyone,

I have a value with format: <div> Hello world! Just bonus some special chars: < > & ! </div>

Expected result: Hello world! Just bonus some special chars: < > & ! 

I've tried to use the HtmlEncode but it displays as "<div> Hello world! Just bonus some special chars: < > & ! </div>"

Can you guys support this issue?

Using Telerik Report Designer and programming language C#

Thanks,

 

4 Answers, 1 is accepted

Sort by
0
Hung
Top achievements
Rank 1
answered on 14 Apr 2021, 09:56 AM

It has been resolved.

[Definition: Entity and character references may both be used to escape the left angle bracket, ampersand, and other delimiters. A set of general entities (amp, lt, gt, apos, quot) is specified for this purpose. Numeric character references may also be used; they are expanded immediately when recognized and must be treated as character data, so the numeric character references " &#60; " and " &#38; " may be used to escape < and & when they occur in character data.]
All XML processors must recognize these entities whether they are declared or not. For interoperability, valid XML documents should declare these entities, like any others, before using them. If the entities lt or amp are declared, they must be declared as internal entities whose replacement text is a character reference to the respective character (less-than sign or ampersand) being escaped; the double escaping is required for these entities so that references to them produce a well-formed result. If the entities gt, apos, or quot are declared, they must be declared as internal entities whose replacement text is the single character being escaped (or a character reference to that character; the double escaping here is optional but harmless). For example:
<!ENTITY lt "&#38;#60;">

<!ENTITY gt "&#62;">

<!ENTITY amp "&#38;#38;">

<!ENTITY apos "&#39;">

<!ENTITY quot "&#34;">

 

Refer to https://www.w3.org/TR/REC-xml/#dt-escape

 

0
Hung
Top achievements
Rank 1
answered on 15 Apr 2021, 10:41 AM
If you have any issue with the char < or &. So you can try to remove #38; out of that value. Example < : "&#60;" and & "&#38;"
0
Neli
Telerik team
answered on 16 Apr 2021, 08:16 AM

Hello Hung,

When it comes to &, you test using &amp; I would suggest taking a look at this w3.org page which lists all special entities like "?" and TAB and their expression that should be used in the HtmlTextBox.

Regards,
Neli
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

0
Hung
Top achievements
Rank 1
answered on 16 Apr 2021, 08:22 AM

Hi Neli,

Firstly, thanks for your answer.

I've tried to use &amp; but it didn't work for me. So that why I've tried to use &#38;

 

Thanks,

Hung Hoang

Tags
General Discussions
Asked by
Hung
Top achievements
Rank 1
Answers by
Hung
Top achievements
Rank 1
Neli
Telerik team
Share this question
or