this example allows you to hard code
protected
string path = "test.html";
but what if users are selecting their files via the template manager dialog - how do i pass that file name to the string path?
23 Answers, 1 is accepted
You can obtain the selected file name by using the following property:
this._currentItem.name
It is located in the external \EditorDialogs\TemplateManager.ascx file and you can pass it as a string value of 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;
var test = this._currentItem.name + document.getElementsByTagName("IFRAME")[0].contentWindow.document.getElementsByTagName("HTML")[0].innerHTML;
return test;
}
return null;
},
You can see how to configure the external dialogs here.
After that attach to the OnClientPasteHtml event and obtain the file name and returned content via the dialog from the args.get_value(); method:
<telerik:RadEditor ID="RadEditor1" ExternalDialogsPath="~/EditorDialogs" OnClientPasteHtml="OnClientPasteHtml" runat="server">
<TemplateManager ViewPaths="~/Uploads" UploadPaths="~/Uploads" />
</telerik:RadEditor>
<script type="text/javascript">
function OnClientPasteHtml(sender, args)
{
var commandName = args.get_commandName();
var value = args.get_value();
if (commandName == "TemplateManager")
{
debugger;
}
}
</script>
All the best,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
trying to use the save / cancel buttons while using the template manager dialog - so that if someone opens a file - they click save and it saves the opened file - only examples i've seen hard codes a file name in.
please point me to a full working example with aspx and c# if available.\
thanks.
i don't understand how to get the file name of the selected file the user chooses via a template manager dialog
protected string path = "test.html" - this is the example and that does work - but that's not going to be the case - the selected filename needs to be passed in.
protected string path = this._currentItem.name - this does not seem to work for me - been at this several days now - seems saving the file back to itself might be a little easier than this.
Here is the requested link http://www.telerik.com/help/aspnet-ajax/customizingimagedialog.html demonstrating how to configure RadEditor to use its external dialog file. When the ExternalDialogsPath="~/EditorDialogs" is set the editor uses its external dialogs located in the EditorDialogs folder. This allows the developer to edit the dialogs and customize them.
When you open the \EditorDialogs\TemplateManager.ascx file you can get the name of the selected in the Template manager html file using the this._currentItem.name js property or the file path with this._currentItem.getUrl(). After that you should supply this name to the page with the editor and set it in a hidden field which will allow you to get the file name / path on the server.
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);
//TODO: Here you need to set this information in a hidden field and to send it to the server
}
</script>
<telerik:RadEditor runat="server" ExternalDialogsPath ="~/EditorDialogs"
ID="RadEditor1">
<TemplateManager ViewPaths="~/" UploadPaths="~/" />
</telerik:RadEditor>
For your convenience I have attached a sample working project.
Best regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
am getting this when clicking on the template dialog
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.Parser Error Message: Could not load file or assembly 'Telerik.Web.UI, Version=2008.3.1105.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
|
Source File: C:\web\test2\web.config Line: 37
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Telerik.Web.UI, Version=2008.3.1105.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4' could not be loaded.
Could you please, delete the version strings from the fully qualified names, e.g.
<add path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI" validate="false"/>
<add path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI" validate="false"/>
Best regards,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
can you add a save and cancel tool button like shown here http://www.telerik.com/help/aspnet-ajax/addingsaveandcancelbuttonstoolbar.html that is hooked up and saves the selected file and send it back - i just don't get it...
everything else i seem to get, and works great.
i don't see how i am able to write the selected file to a label control
in c# i'm used to saying something like
lblSelectedfile.text = dialog.selectedvalue.tostring();
then i would purchase the product.
...
protected void Button1_Click1(object sender, EventArgs e)
{
//Open file for writing and write content
using (StreamWriter externalFile = new StreamWriter(this.MapPath(path), false))
{
externalFile.Write(RadEditor1.Content);
}
}
only test.html will be replaced with the selected file from the template manager dialog - but i am stuck for going on 5 days on and off now - frustration setting in - you provided snippets of js that i am unable to get to work - please help.
this is what i am after
i did get this to work with the file explorer - but...
help me to get it to work for the editor only with the template manager
function
LogEvent(text)
{
var d = new Date();
var dateStr = d.getHours() + ":" + d.getMinutes() + ":" + d.getSeconds() + "." + d.getMilliseconds();
var eventConsole = $get("eventConsole");
eventConsole.innerHTML =
"[" + dateStr + "] " + text + "<br/>" + eventConsole.innerHTML;
var newtext = text;
//alert(newtext);
document.getElementById(
"Label1").innerText = text; // this line was what i have been asking for the whole time
// how do i set the selected file to my c# label control
}
can you or another telerik team member assist me in the last part of this?
Please, find attached the required example demonstrating the whole process, getting the file name of the selected in the template manager file, passing its name value to the server using a hidden field and saving the modified content back in the selected template file.
If your scenario is other, please open a support ticket and send a sample fully working project that demonstrates the problem.
Greetings,
Rumen
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Jeff
My name is Tervel Peykov and I am the Team Leader of the team developing RadEditor for ASP.NET AJAX, as well as other controls from the Telerik RadControls for ASP.NET AJAX. This forum thread was escalated to me, and I reviewed it and I would like to provide my feedback.
Firstly, and most importantly, we would be happy if you decide to become our customer. We do our best to help our customer base timely and adequately, and I believe our forums are a testament of this. However, to be able to resolve reported problems faster, as well as to provide better suggestions it is instrumental that the other side provides sufficient information as well. Since it is not possible to attach files/projects in a forum thread, sometimes this is a reason for taking longer to resolve a scenario. Other times, the reason is misunderstanding what part of the task is directly related to Telerik controls - which is what our support is focused on - and what is a general programming task that is in the developer's domain.
Reviewing the forum thread, I can notice that our support officer has provided you with a number of relevant examples and help articles based on the information provided by you and the questions asked. He has also prepared on two occasions full-blown runnable projects implementing what he believes is your scenario.
From your feedback it is clear that you have not been able to implement the scenario you need just yet. This is why we suggested opening a support ticket instead where you can send us an actual running project, as well as more detailed feedback in the code itself what your needs are and what you are trying to accomplish. Without such a project from you I am afraid we will not be able to help further.
Unofrtunately, we are not able to determine what is going wrong from answers to the tune of
"this attached example does not work...". Your forum answers have been fragmented - focusing on just a couple of lines of code and is unclear how everything fits in your scenario. Still, we have done our best to use this scarce information in a meaningful way.
It is important to note also, that in this particular case, the functionality requested by you is not provided by RadEditor out of the box and we are in fact helping you extend the editor functionality to fit your needs.
For your convenience, I have attached a movie confirming that the project that we sent you works properly.
We are looking forward to receiving a working project from you demonstrating what you have implemented so far, as well as comments for the bits you are missing.
Best regards,
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
everything seems to be working well - except if i make a change, save it, then clear the rad editor and then open the file again - the template preview is not showing the most recent version of the file.
In the movie that we sent you, you can see that the template preview is showing the mot recent version of the template file. You say that this is not the case on your side which leads me to believe that the reason for the behavior is browser's caching - could you please check that. Just empty your browser's cache and see how the application will behave.
If you still experience problems, I would like to ask you again to open a support ticket and send us a fully working project like the one that Rumen attached that shows your implementation and the problem that you have.
Kind regards,
Georgi Tunev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
The JS function invokeTopPageMethod did not fire with version 415 but works OK with 2008.3.1125.20.
what do I need to do to make the Javascript work with 415. Do you have an older example?
Cheers
Matt
This functionality is available only with the current version of the control, I am afraid there is no solution for old versions (the one that you are using is more than 6 months old).
Could you please let me know why upgrading is not an option? The controls are backwards compatible and you should not experience major problems during the upgrade. If any problem occur, we will do our best to help you.
Sincerely yours,
Georgi Tunev
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I have tested with the Q3 1125 library and it is working fine so I guess I'll renew my subscription.
I just downloaded Telerik Web.UI V2009.2 trial version and have the same question how to find the selected file via the template manager.
Do these threads still apply to the new version?
If not, do you have any suggestion for this question?
Thank you for your help.
I just downloaded Telerik Web.UI V2009.2 trial version and have the same question how to find the selected file and folder via the template manager.
Does v2009.2 have the solution for this issue?
Looking forward to your help. Thanks!
We integrated the RadFileExplorer control in the RadEditor file browsers in Q1 2009 and you should update the EditorDialogs folder and the getResult function in the TemplateManager.ascx. You need to replace the old getResult() method with this one get_url(), e.g.
| getResult : function() |
| { |
| if (this._currentItem && this._currentItem.get_type() == Telerik.Web.UI.FileExplorerItemType.File) |
| { |
| //HACK: Provide the name to the parent page so that it can be further recorded into a database |
| window.top.invokeTopPageMethod(this._currentItem.get_url()); |
| return this._currentTemplateItem.contentWindow.document.body.innerHTML; |
| } |
| return null; |
| }, |
For your convenience I have attached a new project that demonstrates the solution with the latest Q2 2009 version.
Greetings,
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.
Hi Rumen,
You're my hero. It works great!
Thank you so much for your help!
