Hi,
I have an Editor with the Template Manager in the tools.
What I need to do is that when a user select a template from the manager - a Textbox is populated with the name of that file.
Basically I am creating a template Save and Manage Area, so I need the name of the selected template.
All help appreciated.
Cheers,
Jon
I have an Editor with the Template Manager in the tools.
What I need to do is that when a user select a template from the manager - a Textbox is populated with the name of that file.
Basically I am creating a template Save and Manage Area, so I need the name of the selected template.
All help appreciated.
Cheers,
Jon
4 Answers, 1 is accepted
0
Hi,
You can easily get the url of the selected and inserted template file using the this._currentItem.getUrl() property in the getResult function in the \EditorDialogs\TemplateManager.ascx control. To supply this information from the dialog to the main page add window.top.invokeTopPageMethod(this._currentItem.getUrl()); , e.g.
getResult : function()
{
if (this._currentItem && this._currentItem.type == Telerik.Web.UI.Widgets.FileItemType.File && this.isValidExtension())
{
//HACK: Provide the name to the parent page so that it can be further recorded into a database
window.top.invokeTopPageMethod(this._currentItem.getUrl());
return this._currentTemplateItem.contentWindow.document.body.innerHTML;
}
return null;
},
and on the main page with the editor add the following function:
< script type="text/javascript">
function invokeTopPageMethod (fileName)
{
alert("The template file name selected was " + filePath);
}
< /script>
< telerik:RadEditor runat="server" ExternalDialogsPath ="~/EditorDialogs"
ID="RadEditor1">
<TemplateManager ViewPaths="~/" UploadPaths="~/" />
< /telerik:RadEditor>
Regards,
Rumen
the Telerik team
You can easily get the url of the selected and inserted template file using the this._currentItem.getUrl() property in the getResult function in the \EditorDialogs\TemplateManager.ascx control. To supply this information from the dialog to the main page add window.top.invokeTopPageMethod(this._currentItem.getUrl()); , e.g.
getResult : function()
{
if (this._currentItem && this._currentItem.type == Telerik.Web.UI.Widgets.FileItemType.File && this.isValidExtension())
{
//HACK: Provide the name to the parent page so that it can be further recorded into a database
window.top.invokeTopPageMethod(this._currentItem.getUrl());
return this._currentTemplateItem.contentWindow.document.body.innerHTML;
}
return null;
},
and on the main page with the editor add the following function:
< script type="text/javascript">
function invokeTopPageMethod (fileName)
{
alert("The template file name selected was " + filePath);
}
< /script>
< telerik:RadEditor runat="server" ExternalDialogsPath ="~/EditorDialogs"
ID="RadEditor1">
<TemplateManager ViewPaths="~/" UploadPaths="~/" />
< /telerik:RadEditor>
Regards,
Rumen
the Telerik team
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 their blog feed now.
0

Jon
Top achievements
Rank 1
answered on 08 Feb 2013, 06:35 AM
Hi Rumen,
Thanks for this but I can't get it going.
I have this in the dialog
and this on the page
when I add in the code
it stops the insert function of the template manager I'm afraid.
Would you perhaps have a sample?
Many thanks,
Jon
Thanks for this but I can't get it going.
I have this in the dialog
getResult : function()
{
if (this._currentItem && this._currentItem.get_type() == Telerik.Web.UI.FileExplorerItemType.File)
{
window.top.invokeTopPageMethod(this._currentItem.getUrl());
return this._currentTemplateItem.contentWindow.document.body.innerHTML;
}
return null;
},
and this on the page
<
script
type
=
"text/javascript"
>
function invokeTopPageMethod (fileName)
{
alert("The template file name selected was " + filePath);
}
</
script
>
<
telerik:radeditor
runat
=
"server"
ID
=
"reTemplates"
Height
=
"600"
Width
=
"984px"
Skin
=
"Metro"
EditModes
=
"Design"
DialogHandlerUrl
=
"~/Telerik.Web.UI.DialogHandler.axd"
TemplateManager-SearchPatterns
=
"*.html, *.htm, *.txt"
ImageManager-SearchPatterns
=
"*.gif, *.jpg, *.jpeg, *.png"
ContentAreaMode
=
"Div"
ExternalDialogsPath
=
"~/_admin/editorDialogs"
>
when I add in the code
window.top.invokeTopPageMethod(this._currentItem.getUrl());
it stops the insert function of the template manager I'm afraid.
Would you perhaps have a sample?
Many thanks,
Jon
0
Accepted
Hi,
I have a typo in the name of this method getUrl(), which should be get_url(). getUrl is old syntax which is not supported in the latest version.
For your convenience I have attached a sample working project.
All the best,
Rumen
the Telerik team
I have a typo in the name of this method getUrl(), which should be get_url(). getUrl is old syntax which is not supported in the latest version.
For your convenience I have attached a sample working project.
All the best,
Rumen
the Telerik team
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 their blog feed now.
0

Jon
Top achievements
Rank 1
answered on 09 Feb 2013, 01:10 AM
Hi Rumen,
That's fantastic - Works like a charm!
Thank you very much.
Jon
That's fantastic - Works like a charm!
Thank you very much.
Jon