This is a migrated thread and some comments may be shown as answers.

[Solved] Add content to Editor programmatically?

3 Answers 262 Views
Editor
This is a migrated thread and some comments may be shown as answers.
John
Top achievements
Rank 1
John asked on 14 Jan 2010, 03:28 PM
Hi all:

I have a ASP.NET page that has a Tabbed interface, 4 data grids, some images, text., etc. I'd like to get all of this content into the RadEditor at Run time...is this possible? I have been able to get string content into the Editor, but is it possible to build a table from a RadGrid and then add that table to the Editor? Is it possible to add and format headers, images, etc?

Thanks for any and all input.

John.

3 Answers, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 15 Jan 2010, 04:47 PM
To set the content programmatically I believe you have to basically define a string for the content which has the HTML representation of what you are attempting to add, like in the following documentation article. There's no way to say "RadEditor1.Content.Add(image)" for example, and the content is handled through the getting and setting of content which is all string-based.
0
John
Top achievements
Rank 1
answered on 15 Jan 2010, 05:19 PM
Hi:

Thanks for your reply and yes, that did work for adding the content from the grid. However for some reason when I added the content programatically the ExportToPDF functionality failed. If I type something below the data I added programatically, the typed content gets exported to teh PDF, but none of the otehr content does. Strange.

John.
0
Rumen
Telerik team
answered on 18 Jan 2010, 02:01 PM
Hi John,

Please, see the following forum thread which demonstrates how to export table elements to PDF documents: Export to PDF/DOC.

The third party HTMLtoPDF converter that RadEditor uses does not offer support for external css files and it does not render the classes specified in the class attributes of the HTML elements. This means that you will be able to apply table borders only with inline styles. You can do that in the custom content filter by adding this line in it:

table.style.border = "1px solid red";

To apply borders to the internal cells you should loop through the table cells and apply border to them.     
The line below demonstrates how to apply a border to the first cell in the table:

table.rows[0].cells[0].style.border = "1px solid red";

2) To export fonts you follow this rule - the first letter of the font name should start with uppercase letter:


Dim outstr As String = RadEditor1.Content
 
'Telerik: The first letter of all font names should be uppercase
outstr = outstr.Replace("arial", "Arial")
outstr = outstr.Replace("tahoma", "Tahoma")
outstr = outstr.Replace("garamond", "Garamond")
outstr = outstr.Replace("verdana", "Verdana")
outstr = outstr.Replace("georgia", "Georgia")
outstr = outstr.Replace("courier new", "Courier New")

The improvement of the Export To PDF tool is on our ToDo list for Q1 2010.

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Editor
Asked by
John
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
John
Top achievements
Rank 1
Rumen
Telerik team
Share this question
or