2X faster development
The ultimate ASP.NET MVC UI toolkit to boost your development speed.
ProblemRTE value set from code behind with multiple spaces are not visibly shown in browser. ReasonWithin the HTML, we cannot change the output by adding extra spaces in HTML code. Since the browser will remove extra spaces when the page is displayed and any number of spaces will count as only one space. Refer this link for in detailed description.
Solution
On setting RTE value from code behind, which has multiple spaces can be handled in two ways.
public ActionResult RichTextEditorFeatures() { var model = new MyClass { RTEValue = "This is test for RTE Sample with multi spaces" }; return View(model); } public class MyClass { public string RTEValue { get; set; } }
@{Html.EJ().RTE("rteSample").Width("100%").Locale("en-US").ContentTemplate(@<p> </p>).ShowFooter(true).ClientSideEvents(ce => ce.Create("onCreate")).EnableXHTML(true).Value(Model.RTEValue).Render();}
function onCreate(args) { $("#rteSample").ejRTE({ value: this._getDocument().body.textContent.replace(/ /g, " ")}); }
public ActionResult RichTextEditorFeatures() { var model = new MyClass { RTEValue = "This is test for RTE Sample with multi spaces" }; return View(model); } public class MyClass { public string RTEValue { get; set; } }
@{Html.EJ().RTE("rteSample").Width("100%").Locale("en-US").ContentTemplate(@<p> </p>).ShowFooter(true).ClientSideEvents(ce => ce.Create("onCreate")).EnableXHTML(true).Value(Model.RTEValue).Render();}
function onCreate(args) { $(this.getDocument().body).css({ "white-space": "pre-wrap" }); }
Figure 1: RTE Value set with multiple spaces |
2X faster development
The ultimate ASP.NET MVC UI toolkit to boost your development speed.
This page will automatically be redirected to the sign-in page in 10 seconds.