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

[Solved] Add Controls within RadEditor

1 Answer 85 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Ceramist
Top achievements
Rank 1
Ceramist asked on 15 Jun 2009, 05:07 PM
Is it possible to render a usercontrol within a RadEditor document?

I typically create usercontrols for my RadGrid (ItemTemplate) to display data.  My users would like to put that same data in a document they create.  Could I programmatically simply add into the document a correct reference to the control?  Or could i extract from a copy of the UserControl the outputted HTML and insert that into the RadEditor document?

1 Answer, 1 is accepted

Sort by
0
Accepted
Rumen
Telerik team
answered on 16 Jun 2009, 12:36 PM
Hi Walter,

RadEditor is an HTML / XHTML editor and it could not parse and render server controls. What you can do is to create a custom dialog that will load some data from the database or server and you can paste it in the content area using the pasteHtml client method of the editor. You can see an example on how to create a custom dialog here.

Another approach is to use custom tags and replace them with information on the server. The rich text editing engine of the browser, which RadEditor uses, does not offer support for custom tags out-of-the box and it cannot render them, however your can style them and put content in them:

<MY:FULLNAME style="border:solid 1px red;">Name</MY:FULLNAME>

After that you can replace this custom tags with the desired content on the server using the String.Replace method.

For example put in the content area custom tags with namespaces that will be replaced later on the server with the desired strings:

<radE:RadEditor id="RadEditor1" Runat="server" >

<p>Hello <MY:FULLNAME>Name</MY:FULLNAME>
,<br/><MY:PHONE>Phone Number</MY:PHONE>
</p>

</radE:RadEditor>

Please, note that you need to use custom tags with namespace, because they are supported by the browser and it will not modify them.

After that use

RadEditor1.Content = RadEditor1.Content.Replace("<MY:FULLNAME>Name</MY:FULLNAME>", "Peter").Replace("<MY:PHONE>Phone Number</MY:PHONE>", "324324324");

to replace the predefined text fields with the desired strings

Best regards,
Rumen
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Editor
Asked by
Ceramist
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Share this question
or