Details View and integration with TinyMCE <%@ Page validateRequest="false" %>
Posted
by
GibboK
on Stack Overflow
See other posts from Stack Overflow
or by GibboK
Published on 2010-12-21T12:24:31Z
Indexed on
2012/10/26
5:02 UTC
Read the original article
Hit count: 253
I use TinyMCE in a DetailView in in EDIT MODE.
I would like to know if there is a solution which can prevent Request Validation to trigger an error
WITHOUT USING <%@ Page validateRequest="false" %>
for my page.
The only way I found out at the moment is to encode TextBox used by TinyMCE using option: "xml"
tinyMCE.init({
encoding: "xml",
In this way Request Validation does not trigger error but at the time to read the data in the TextBox the result it is Encoded. I also tried to Decode on PageLoad the content of the TextBox using this code
myTextBox.Text = HttpUtility.HtmlDecode(myTextBox.Text)
But the result is not as expected, so I can visualize it just Encoded text.
Any Ideas? Thanks
UPDATE
I found a solution to my problem. I added in _DataBound event for the DetailsView this code
TextBox myContentAuthor = (TextBox)uxAuthorListDetailsView.FindControl("uxContentAuthorInput");
myContentAuthor.Text = HttpUtility.HtmlDecode(myContentAuthor.Text);
So on DataBound event, (should work even on post back) the content will be decodene for textbox tinymce.
Here how should work:
01 - TinyMCE ESCAPE data inserted in textbox using function encoding: "xml",
02 - Data has been stored as ESCAPED
03 - To read the data and add its content to a TextBox where apply TinyMCE use in DATABOUND EVENT for DetailView and HttpUtility.HtmlDecode (so it will look decoded)
04 - You can modify content in the textbox in edit mode. On post back TinyMCE will encoded again using encoding: "xml" an so on
Hope guys can help some one else.
But please give me your comment on this solution thanks! Mybe you come up with more elegant solution! :-)
© Stack Overflow or respective owner