开发者

Details View and integration with TinyMCE <%@ Page validateRequest="false" %>

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! :-)


I personally would simply turn request validation off for this page.

Unless there are issue you forsee with cross site requests etc, there would be no need to shelter under its assumed "protection"


this can also be done by removing html tags from the data before the page postback.


The problem is :
When a PostBack arrived, TinyMCE re-encode the content of the textarea. To resolve this problem, the solution is easier than explain...

In the Page_Load, you must test if it's a PostBack -> You replace the myTextBox.Text by HttpUtility.HtmlDecode(myTextBox.Text)

I try, it's work...

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜