[RESOLVED]How to Implement a CKeditor in MVC

Hi,

I am newibe in MVC. I have a visual studio 2012. I want to create an mvc application.In this Application , want to use CkEditor In MVC.I want to enter some text in CK editor textbox and insert this text into a table as html string.Am using Sql server 2008
.Want to insert the data through ADO.net class and not through entiity framework.Pls provide some sample solution

Regards,

Dileep

 

for the ckeditor open up nuget and search for ckeditor.mvc

first of all you have to know examples aren’t just given here it’s a support forum not a school or whatever.

the easiest way for you to get this to work is with a viewmodel 

in this viewmodel you make a property and give it the attribute [allowhtml] you can use attributes on these properties something like:

public class BlogEntry {

    [AllowHtml] 
    public string BlogText {get;set;}
 }

now make a new method in your controller TestMethod

        public ActionResult TestMethod()
        {
            return View(new BlogEntry());
        }

        [HttpPost]
        public ActionResult TestMethod(BlogEntry be)
        {
             //send to db
            return View(be);
        }

in your view you need to reference a model at the top of the page, something like:

@model MyProject.ViewModels.BlogEntry

it is important when you use custom inputs like the ckeditor that you fill up id and name attributes on there the same as your model

in this case BlogText so a normal input would look like:

<input type="text" id="BlogText" name="BlogText" />

if you put that within a form tag with a submit button in it it will automaticly fill the model in your controller on post

hope this helps you a little bit :)

Hi,

Can ypuls eaplian step by step or samples with details.

Regards,

Dileep Sanker

Hi dileep,

Thanks for your post.

dileep Sanker

Can ypuls eaplian step by step or samples with details.

You can follow this:

Using CKEditor with Razor for .NET MVC 3

http://peterkeating.co.uk/using-ckeditor-with-razor-for-net-mvc3/

and here is a similar thread:

http://www.experts-exchange.com/Programming/Microsoft_Development/Q_28257325.html

Hope this can be helpful.

Best Regards,

Eileen

Leave a Reply