3 Answers, 1 is accepted
0
Hi Jeff,
How do you upload the file? Do you use one of the RadEditor FileBrowser dialogs?
Please, give us steps to reproduce and more information on what you do.
Our suggestion is to open a support ticket - send us a sample html file for us to upload and more information how you test that a tag is missing.
Please, note that if you insert the uploaded file through the template manager in the editor, the browser will automatically strip the html, head and body tags. The meta tag will be also stripped because it is not possible to place a meta tag in the body.
If this is your scenario, you can insert a full html page through the template manager by following the steps below:
Kind regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
How do you upload the file? Do you use one of the RadEditor FileBrowser dialogs?
Please, give us steps to reproduce and more information on what you do.
Our suggestion is to open a support ticket - send us a sample html file for us to upload and more information how you test that a tag is missing.
Please, note that if you insert the uploaded file through the template manager in the editor, the browser will automatically strip the html, head and body tags. The meta tag will be also stripped because it is not possible to place a meta tag in the body.
If this is your scenario, you can insert a full html page through the template manager by following the steps below:
- Place the EditorDialogs installation folder to the root of your web application
- Set the ExternalDialogsPath property to point to the EditorDialogs folder, e.g.
<telerik:RadEditor ID="RadEditor1" ExternalDialogsPath="~/EditorDialogs"
OnClientPasteHtml="OnClientPasteHtml" runat="server">
<Content>
</Content>
<TemplateManager ViewPaths="~/files" UploadPaths="~/files" />
</telerik:RadEditor>
- Open the \EditorDialogs\TemplateManager.ascx dialog file and modify the getResult function:
getResult : function()
{
if (this._currentItem && this._currentItem.type == Telerik.Web.UI.Widgets.FileItemType.File && this.isValidExtension())
{
//OLD
//this._currentTemplateItem.contentWindow.getElementsByTagName("HTML")[0].innerHTML;
//NEW
var test = "<html>" + document.getElementsByTagName("IFRAME")[0].contentWindow.document.getElementsByTagName("HTML")[0].innerHTML + "</html>";
return test;
}
return null;
},
...
This change will return full html content to the editor on the parent window.
- Since
the browser itself will strip the <html>, <head> and
<body> tags, we need to capture the supplied content from the
Template manager and paste it in the editor with the set_html() method.
We can do that by attaching to the OnClientPasteHtml event property of
RadEditor, e.g.
<telerik:RadEditor ID="RadEditor1" OnClientPasteHtml="OnClientPasteHtml" ExternalDialogsPath="~/EditorDialogs" runat="server">
<Content>
</Content>
<TemplateManager ViewPaths="~/files" UploadPaths="~/files" />
</telerik:RadEditor>
<script type="text/javascript">
function OnClientPasteHtml(editor, args)
{
var commandName = args.get_commandName(); //returns the command name
var value = args.get_value(); //returns the content / value of the fired command
if (commandName == "TemplateManager")
{
editor.set_html(value);
}
}
</script>
Kind regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0

Jeff
Top achievements
Rank 1
answered on 11 Jan 2009, 12:26 AM
Rumen,
time finally permitted me to take another shot at this - the example you sent me sure does work at keeping the html in tact for an upload - however if you select an existing file it puts the content in twice - please help - thanks much - happy new year.
Jeff
time finally permitted me to take another shot at this - the example you sent me sure does work at keeping the html in tact for an upload - however if you select an existing file it puts the content in twice - please help - thanks much - happy new year.
Jeff
0
Hi Jeff,
Please, excuse me for the omission.
To fix the double paste problem, you should cancel the paste command that is fired after the set_html method execution. You can do that by setting args.set_cancel(true); below the editor.set_html(value); line, e.g.
<telerik:RadEditor ID="RadEditor1" OnClientPasteHtml="OnClientPasteHtml" ExternalDialogsPath="~/EditorDialogs" runat="server">
<Content>
</Content>
<TemplateManager ViewPaths="~/files" UploadPaths="~/files" />
</telerik:RadEditor>
<script type="text/javascript">
function OnClientPasteHtml(editor, args)
{
var commandName = args.get_commandName();
var value = args.get_value();
if (commandName == "TemplateManager")
{
editor.set_html(value);
args.set_cancel(true);
}
}
</script>
All the best,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Please, excuse me for the omission.
To fix the double paste problem, you should cancel the paste command that is fired after the set_html method execution. You can do that by setting args.set_cancel(true); below the editor.set_html(value); line, e.g.
<telerik:RadEditor ID="RadEditor1" OnClientPasteHtml="OnClientPasteHtml" ExternalDialogsPath="~/EditorDialogs" runat="server">
<Content>
</Content>
<TemplateManager ViewPaths="~/files" UploadPaths="~/files" />
</telerik:RadEditor>
<script type="text/javascript">
function OnClientPasteHtml(editor, args)
{
var commandName = args.get_commandName();
var value = args.get_value();
if (commandName == "TemplateManager")
{
editor.set_html(value);
args.set_cancel(true);
}
}
</script>
All the best,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.