I've just finished putting together a trivial ASP.NET Dynamic Data project and in the process I created a custom field template for editing rich text that uses FCKeditor. If there's any interest in the subject I'd be happy to write something up and post it in this forum.
Tue, 08/26/2008 - 22:14
#1
Re: FCKeditor and ASP.NET Dynamic Data
Tnx
Re: FCKeditor and ASP.NET Dynamic Data
Okay, if you haven't already done so review the ASP.NET Integration documentation at:
http://docs.fckeditor.net/FCKeditor_2.x ... on/ASP.NET
Once you're on top of that go ahead and fire up a Dynamic Data project and add two new field templates under the DynamicData\FieldTemplates folder. I named mine FCKeditor.ascx and FCKeditor_Edit.ascx.
For the read-only field template (FCKeditor.ascx) I just used a span because all I needed was something to render HTML. The contents of FCKeditor.ascx looks like this:
<%@ Control Language="C#" CodeBehind="FCKeditor.ascx.cs" Inherits="WebApplication1.EditorField" %>
<span id="FCKeditor1" runat="server">
<%# FieldValueEditString %>
</span>
The contents of the read/write field template (FCKeditor_Edit.ascx) looks like this:
<%@ Control Language="C#" CodeBehind="FCKeditor_Edit.ascx.cs" Inherits="WebApplication1.FCKeditor_EditField" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<FCKeditorV2:FCKeditor ID="FCKeditor_Edit1" BasePath="~/fckeditor/" Value="<%# FieldValueEditString %>"
runat="server" ToolbarSet="AAGI" Width="700" Height="300">
</FCKeditorV2:FCKeditor>
<asp:RequiredFieldValidator runat="server" ID="RequiredFieldValidator1" ControlToValidate="FCKeditor_Edit1" Display="Dynamic" Enabled="false" />
<asp:RegularExpressionValidator runat="server" ID="RegularExpressionValidator1" ControlToValidate="FCKeditor_Edit1" Display="Dynamic" Enabled="false" />
<asp:DynamicValidator runat="server" ID="DynamicValidator1" ControlToValidate="FCKeditor_Edit1" Display="Dynamic" />
The only other thing I had to do was create a partial class to extend the LINQ-to-SQL partial class and decorate the appropriate member(s) with the UIHint. My partial class looks something like this:
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel.DataAnnotations;
using System;
namespace Projects
{
[MetadataType(typeof(ProjectMetaData))]
public partial class Project
{
}
public class ProjectMetaData
{
[UIHint("FCKeditor")]
public object ItemDetails { get; set; }
}
}
Re: FCKeditor and ASP.NET Dynamic Data
Re: FCKeditor and ASP.NET Dynamic Data
Broomeister, I try your code, and I have one problem, the text from FCKEditor didn't save it to database. If I use textbox control everything working well. Would you have any idea why it not working?
t56
Re: FCKeditor and ASP.NET Dynamic Data
Can view/edit in FCKeditor fine, but can't save.
Re: FCKeditor and ASP.NET Dynamic Data
Anyone else run into this issue and figured out a workaround/fix? I'm really stumped
Re: FCKeditor and ASP.NET Dynamic Data
What worked for me is the following code-behind:
public partial class DynamicData_FieldTemplates_NewsText_EditField : System.Web.DynamicData.FieldTemplateUserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected override void ExtractValues(IOrderedDictionary dictionary)
{
dictionary[Column.Name] = ConvertEditedValue(HttpUtility.HtmlDecode(FCKeditor1.Value));
}
public override Control DataControl
{
get
{
return FCKeditor1;
}
}
}
Hope this helps!
Re: FCKeditor and ASP.NET Dynamic Data
Re: FCKeditor and ASP.NET Dynamic Data
Thanks
Re: FCKeditor and ASP.NET Dynamic Data
Hi all,
I've also struggled with on how to implement CKEditor with .NET 4.0 (VisualStudio 2010) DynamicData website.
My solution can be found here, it's the second answer:
http://stackoverflow.com/a/11689200/874160
Notice that my solution is for the currently latest version CKEditor 3.6.2. Works nicely.
Can view/edit in FCKeditor
Can view/edit in FCKeditor fine, but can't save.