Search code examples
asp.netckeditortinymceupdatepanelrichtextbox

Updatepanels not working when filling the CKEditor / Tinymce from the Database


I am developing website by using ASP.NET and I am using CKEditor as a richtextbox. In there everythings works fine.

I am using this code to achieve it

<asp:TextBox ID="txtDescription" runat="server" Width="100%" TextMode="MultiLine" Rows="15" AutoComplete="off" ClientIDMode="Static" MaxLength="6000"></asp:TextBox><br />

<script src="//cdn.ckeditor.com/4.5.3/basic/ckeditor.js"></script>
<script type="text/javascript">
    window.onload = function () {
        CKEDITOR.replace('txtJobDescription');
        CKEDITOR.config.htmlEncodeOutput = true;
    };
</script>

So everythings works fine.When I save the content of the textbox I am using

HttpUtility.HtmlDecode(txtDescription.Text)

to do it.

Probelem is when I read the saved text from DB and assigned it to Ckeditor text box all the updatepanels in that page are not working.(Which are working properly) To assign it I am using this code.

    DataTable dt=new DataTable
    dt = objBLL.Get(); 
    txtName=Text= dt.Rows[0]["name"].ToString();
    txtDescription.Text = dt.Rows[0]["description"].ToString();

If I comment the last statement all the updatepanels are working properly. I tried this with tinymce also. Probelem is same. Whats wrong with my code?


Solution

  • I am answering to my own question.

    You can either set page ValidateRequest=off at the page level. But this will make other textboxes also post HTML content.

    So to avoid that use ValidateRequestMode=disabled in specific control.

    This will allow only the selected control posting the HTML tags to server.