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

Insert Template from code behind

1 Answer 57 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Rishi
Top achievements
Rank 1
Rishi asked on 23 Oct 2013, 05:20 PM
Hi 

I was trying to achieve the following with no much success

I want to insert one of the templates into the radeditor content from code behind.
I was not able to figure out what properties I have to access to pick the right template and assign it to the RadEditor textbox content ?

Thanks

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 24 Oct 2013, 11:40 AM
Hello Harisha,

The desired functionality cannot be implemented with built-in properties. From the code behind the editor is expected to be set with an ordinary string value by design.

You could use a custom implementation, which gets the html file, retrieve its content as text and sets the editor's content with the value of the body elements.

This is an example code, which is working fine on my end:
string mslinepath = Server.MapPath("TemplateFolder/template.html");
string htmlCode = File.ReadAllText(mslinepath);
 
int startIndex = htmlCode.IndexOf("<body");
int endIndex = htmlCode.IndexOf("</html>");
 
string content = htmlCode.Substring(startIndex, endIndex - startIndex);
RadEditor1.Content = content;

Regards,
Ianko
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Editor
Asked by
Rishi
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or