Hey All,
Haven't seen any postings for ASP.NET integration of CKEditor 3.x so just thought I'd share some code I used to get it working.
Notes: Windows 2003 Server, IIS 6, Visual Studio 2008, SQL Server 2008, c#
So in a nutshell, used FCKEditor 2.4 originally with a data store to house the content.
Created Textarea HTML element with runat="server"
Since having it defined as a server side HTML control now, have to be concerned about the generated client side ID for use in the Javascript for the CKEditor.replace. So used code behind (c#) to generate the required script
editor1.ClientID will get us the correct client side id for the replace to work.
You can call the function on the Page_Load operation and that should generate the editor for you.
The rest (not shown) is common calls to load the HTML control with the data pulled for my data store and to update/insert as well.
Just a quick start...
HTH
Dave
Haven't seen any postings for ASP.NET integration of CKEditor 3.x so just thought I'd share some code I used to get it working.
Notes: Windows 2003 Server, IIS 6, Visual Studio 2008, SQL Server 2008, c#
So in a nutshell, used FCKEditor 2.4 originally with a data store to house the content.
Created Textarea HTML element with runat="server"
<textarea rows="20" cols="70" name="editor1" id="editor1" runat="server"></textarea>
Since having it defined as a server side HTML control now, have to be concerned about the generated client side ID for use in the Javascript for the CKEditor.replace. So used code behind (c#) to generate the required script
private void BuildJS() { StringBuilder _js = new StringBuilder(); _js.AppendLine("<script type='text/javascript' language='javascript'>"); _js.AppendLine("CKEDITOR.replace( '" + editor1.ClientID + "' );"); _js.AppendLine("</script>"); ClientScript.RegisterStartupScript(GetType(), "CKEditor", _js.ToString()); }
editor1.ClientID will get us the correct client side id for the replace to work.
You can call the function on the Page_Load operation and that should generate the editor for you.
The rest (not shown) is common calls to load the HTML control with the data pulled for my data store and to update/insert as well.
Just a quick start...
HTH
Dave
Re: CKEditor 3.x and Asp.Net
But have you run it or test it?
I'm getting "A potentially dangerous Request.Form value was detected from the client (CKeditor1="<p>
My Text</p...")."
And my analysis is:
Text area RunAt server and on form submit CKeditor updates the text area with its content as is, that content is not encoded and sent to the server as HTML tags causing potential dangerous request.
And setting ValidateRequest = false is not recommended option, as you disable security feature.
Any solutions?
Re: CKEditor 3.x and Asp.Net
Yes you set ValidateRequest = false
but on the serve side use Microsoft Anti-Cross Site Scripting Library http://msdn.microsoft.com/en-us/library/aa973813.aspx to strip out and script tags etc
Re: CKEditor 3.x and Asp.Net
Instead add the following to CKeditor's config file:
And then do this in your .NET code
C#:
VB:
Re: CKEditor 3.x and Asp.Net
Here is my solution for ASP.NET in C#
CkEditor configuration: config.js
Re: CKEditor 3.x and Asp.Net