CKEditor behaves strangely when it loads razor view content. Here is the example:

@model MVC4_With_Custom_CMS.Models.LoginModel
@using System.Web.Mvc

@{
    ViewBag.Title = "Log in";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<hgroup class="title">
    <h1>@ViewBag.Title.</h1>
</hgroup>
........

It will be loaded as:

@model MVC4_With_Custom_CMS.Models.LoginModel @using System.Web.Mvc @{ ViewBag.Title = &quot;Log in&quot;; Layout = &quot;~/Views/Shared/_Layout.cshtml&quot;; }
<hgroup class="title">
    <h1>@ViewBag.Title.</h1>
</hgroup>

You see here, ckeditor automatically removes new line that makes the @model, @using, @{ stay in the same line. This also occurs when we save the ckeditor content, the ckeditor will automatically removes new line.

The problem is that i cannot compile syntax like this, the razor compiler will throw errors.

Is there a way to not let ckeditor auto removing new lines?

Related posts

Recent Viewed