We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to send data from the server side

Hello,

I tried the RichTextEditor control these days,

Now I have an important issue needs to be solved.

The View page code is:

//=======================================================
@Html.EJ().RTE("rteSample").ContentTemplate(@<div id="textcontent1">

&lt;p&gt;&lt;b&gt;Description:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style='list-style-type: square;'&gt;&lt;li&gt;The Rich Text Editor (RTE) control is an easy to render in client side.&amp;nbsp;&lt;br&gt;&lt;/li&gt;&lt;li&gt;Customer easy to edit the contents and get the HTML content for the displayed content.&lt;br&gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;A rich text editor control provides users with a toolbar that helps them to apply rich text formats to the text entered in the text area.&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;

</div>).Width("820px").ToolsList(toolsList).Tools(tool => tool.Styles(style).Lists(lists).DoAction(doAction).Links(links).Images(images))
//=======================================================

It will worked well, please refer to the 001.png.

But when I used @Viewbag.content and send data, it is defined as string.

Will not compiled as HTML,please refer to the 002.png.

The Demo code is:
//=======================================================
//Controller
public ActionResult Demo()
{
    Viewbag.content="&lt;p&gt;&lt;b&gt;Description:&lt;/b&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ul style='list-style-type: square;'&gt;&lt;li&gt;The Rich Text Editor (RTE) control is an easy to render in client side.&amp;nbsp;&lt;br&gt;&lt;/li&gt;&lt;li&gt;Customer easy to edit the contents and get the HTML content for the displayed content.&lt;br&gt;&lt;/li&gt;&lt;li&gt;&amp;nbsp;A rich text editor control provides users with a toolbar that helps them to apply rich text formats to the text entered in the text area.&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;/p&gt;";
    return View();
}

//View

@Html.EJ().RTE("rteSample").ContentTemplate(@<div id="textcontent1">

@Viewbag.content

</div>).Width("820px").ToolsList(toolsList).Tools(tool => tool.Styles(style).Lists(lists).DoAction(doAction).Links(links).Images(images))

//=======================================================

How did you do to send an HTML format from Controller to View?

Looking forward to your response.

Thanks a lot.

Best regards.



Attachment: pics_17ea2103.zip

1 Reply

KR Keerthana Rajendran Syncfusion Team August 10, 2017 09:36 AM UTC

Hi Jacob,     
   
Thank you for contacting Syncfusion Support.   
   
We suggest you to use @Html.Raw to display the Html in the correct format. Please refer to the below given code   
   
@{Html.EJ().RTE("rteSample").Width("100%").Locale("en-US").ContentTemplate(@<div id="textcontent1">   
    @Html.Raw(@ViewBag.Content)</div>).ShowFooter(true).Tools(tool => tool.Clear(clear).FormatStyle(formatStyle).Tables(tables).Links(links).Images(images).Effects(effects).Casing(casing).Font(font).Styles(style).Media(media).Alignment(alignment).Lists(lists).Clipboard(clipboard).DoAction(doAction).Indenting(indenting).View(view).Edit(Edit).Print(Print).CustomOrderedList(customOrder => customOrder.Css("e-rte-toolbar-icon e-rte-listitems customOrder").ListStyle("lower-greek").Name("orderInsert").Tooltip("Custom OrderList").Text("Lower-Greek").Add()).CustomUnorderedList(customUnOrder => customUnOrder.Css("e-rte-toolbar-icon e-rte-unlistitems customUnOrder").ListImage("url('../../Content/images/RichTextEditor/Smiley-GIF.gif')").Name("unOrderInsert").Text("Smiley").Tooltip("Custom UnOrderList").Add())).Render();}   
   
   
We have prepared a sample for reference. Please download the sample from the below link   
   
   
Regards,   
Keerthana.  
 


Loader.
Live Chat Icon For mobile
Up arrow icon