Reputation: 25370
I know the basics of asp.net MVC, and want to create a nice little blog from scratch. As for the blog portion, I need a rich text editor. CKEditor looked good, but I'm curious as to how to save/retrieve rich text from a database. It will be mostly images and text. Is there an easy way to do this? Any tips would be greatly appreciated.
Thanks
EDIT: Thanks for the advice, I'll look into both answers. But no matter what I choose, is there a simple way to store/retrieve rich text from SQL? Again with mostly images and text throughout.
Upvotes: 2
Views: 2224
Reputation: 3637
if you are OK with TinyMCE, you can install it from nuget
PM> Install-Package TinyMCE
it will automatically create editor templates in your Views.
and in your model, just need:
[UIHint("TinyMCE_yourtemplatename"), AllowHtml]
public string Content { get; set; }
Upvotes: 6
Reputation: 47784
CKEditor can easily be integrated with ASP.NET MVC.
You can integrate this with an HtmlEditorFor
and post the values to the controller. (Will post an example soon Article)
So say I have a formatted a text using this CkEditor
This is a link. This is bold
So when posted back to the controller, the values recieved will be something like
This is a <a href="http:www.stackoverflow.com">link</a> . This is <b>bold</b>
and this value will be saved in database, so that covers the saving part.
Now to retrieve and display this formatted content, you can simply use @Html.Raw()
and pass this content as parameter to this method, and the formatted text will appear.
Upvotes: 2