HTMLEditorExtender encodes img tag in async postback

I use the standard HTMLEditorExtender control (part of the ajax toolkit). In the original pageLoad, I fill it with html (including> p <,> br <,> strong <and> img <tags. It displays the HTMLEditorExtender control perfectly. Then, when I do the asynchronous postback (via the updated panel), all> img <tags are displayed as actual html instead of displaying the image. All other tags are still displayed correctly.

The layout of the HTMLEditorExtender control is as follows after the async postback: In the invisible text area used to store the html encoded value, all valid tags are correctly encoded (i.e., <and>), but img tags skip the ampersand before the encoded value (i.e. lt; and gt;).

UPDATE: it works fine if I put this code in my pageLoad event, but I fear what security implications does it have?

if (IsPostBack) { txtBookingConfirmation.Text = Server.HtmlDecode(txtBookingConfirmation.Text); } 

Can someone tell me how to prevent control from doing this?

Thanks in advance

+4
source share
2 answers

This seems to be the only solution and has not yet caused problems.

 if (IsPostBack) { txtBookingConfirmation.Text = Server.HtmlDecode(txtBookingConfirmation.Text); } 
+7
source

I have the same problem. Whenever I click the button that returns to the page, the HTMLEditorExtender changes the contents of the text box where the HTML markup is displayed. It looks like it replaces everything with &. from "&". So, for example, all "& lt;" values ​​in the text get changed to "& lt;". This also happens with & gt. I just upgraded to the AJAX toolkit that was released on 5/1/2012. Not sure which version.

I had to put a space in & and the like, as they ended up at my post. Just take the space when you look at it.

0
source

Source: https://habr.com/ru/post/1394571/


All Articles