Pregunta

I'm using a standard HTMLEditorExtender control (part of the ajax control toolkit). In the original pageLoad I populate it with html (including >p<, >br<, >strong< and >img< tags. It displays fine in the HTMLEditorExtender control. Then, when I do a async postback (through an updatepanel), all the >img< tags display as the actual html instead of displaying the image. All the other tags are still displaying correctly.

The markup of the HTMLEditorExtender control is as follows after the async postback: In the invisible textarea used to keep the encoded value of the html, all the tags displaying correctly are encoded normally (i.e. < and >), but the img tags omit 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'm wary of what security implications this has?

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

Can anyone please tell me how to prevent the control from doing this?

Thanks in advance

¿Fue útil?

Solución

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

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

Otros consejos

I am having this same issue. Whenever I click a button that posts back to the page, the HTMLEditorExtender changes the contents of the textbox to where the HTML markup is showing. It looks like it is replacing all of the "&" with "& amp;". So, for instance, all of the "& lt;" values in the text are getting changes to "& amp;lt;". This is happening with the "& gt" too. I just upgraded to the AJAX toolkit that was released on 5/1/2012. Not sure what version that is.

I had to put a space in "& amp;" and the like since they were rendering on my post. Just take the space out when you look at this.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top