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

[Solved] how do i find the file selected via the template manager dialog?

23 Answers 320 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 23 Nov 2008, 02:25 AM
http://demos.telerik.com/aspnet/prometheus/Editor/Examples/SaveInExternalFile/DefaultCS.aspx

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

Sort by
0
Rumen
Telerik team
answered on 24 Nov 2008, 02:54 PM
Hello Jeff,

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.
0
Jeff
Top achievements
Rank 1
answered on 25 Nov 2008, 04:03 AM
this link did not work - http://www.telerik.com/community/forums/args.get_value%28%29;

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.
0
Jeff
Top achievements
Rank 1
answered on 25 Nov 2008, 05:16 AM
http://demos.telerik.com/aspnet/prometheus/Editor/Examples/SaveInExternalFile/DefaultCS.aspx

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.
0
Rumen
Telerik team
answered on 26 Nov 2008, 02:35 PM
Hi Jeff,

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.
0
Jeff
Top achievements
Rank 1
answered on 26 Nov 2008, 03:29 PM
Rumen,

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:

Line 35: 			<add path="*_AppService.axd" verb="*" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
Line 36: 			<add path="ScriptResource.axd" verb="GET,HEAD" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
Line 37: <add path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Version=2008.3.1105.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false"/>Line 38: 			<add path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI, Version=2008.3.1105.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false"/>
Line 39: 			<add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI, Version=2008.3.1105.20, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false"/>

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.
0
Rumen
Telerik team
answered on 26 Nov 2008, 04:24 PM
Hi Jeff,

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.
0
Jeff
Top achievements
Rank 1
answered on 26 Nov 2008, 05:26 PM
ok it works, and i've set the view path property before and had it working like this but... i'm still unclear on how to save it back to the selected file

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();



0
Jeff
Top achievements
Rank 1
answered on 27 Nov 2008, 12:45 AM
If you could just write the selected file name to an asp label control i can do the save events using the IO examples

then i would purchase the product.

0
Jeff
Top achievements
Rank 1
answered on 27 Nov 2008, 02:11 AM
i plan on using this 

protected string path = "test.html"; //specify the path to your file
...
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.
0
Jeff
Top achievements
Rank 1
answered on 29 Nov 2008, 03:38 AM

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

 

 

 

}

0
Jeff
Top achievements
Rank 1
answered on 02 Dec 2008, 02:22 AM
Rumen,

can you or another telerik team member assist me in the last part of this?
0
Rumen
Telerik team
answered on 02 Dec 2008, 02:15 PM
Hi Jeff,

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.
0
Jeff
Top achievements
Rank 1
answered on 04 Dec 2008, 04:48 AM
this attached example does not work... please double check the code and submit a working copy - please have a peer take a look at the new file as this has been quite some time that i have been requesting assistance on this. I would have spent 999.00 by now as everything else works well.

Jeff
0
Tervel
Telerik team
answered on 04 Dec 2008, 08:31 AM
Hello 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,
Tervel Peykov
Telerik

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Jeff
Top achievements
Rank 1
answered on 06 Dec 2008, 03:49 AM

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.

0
Georgi Tunev
Telerik team
answered on 08 Dec 2008, 03:15 PM
Hi Jeff,

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.
0
Matt
Top achievements
Rank 2
answered on 09 Dec 2008, 06:02 AM
I tried this code with Telerik.Web.UI 2008.1.415.20, I need this functionality for an existing app and upgrading the software is not an option.

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
0
Georgi Tunev
Telerik team
answered on 09 Dec 2008, 02:50 PM
Hi 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.
0
Matt
Top achievements
Rank 2
answered on 09 Dec 2008, 07:33 PM
The last time I tried to migrate from 415 to I think 619 Q1, all the editor dialogs stopped working in our application so I had to rollback to 415.

I have tested with the Q3 1125 library and it is working fine so I guess I'll renew my subscription.
0
John
Top achievements
Rank 1
answered on 20 Jul 2009, 06:09 PM
Hi Rumen,
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.
0
John
Top achievements
Rank 1
answered on 22 Jul 2009, 09:38 PM
Hi Georgi,
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!
0
Rumen
Telerik team
answered on 23 Jul 2009, 09:50 AM
Hi John,

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.
0
John
Top achievements
Rank 1
answered on 23 Jul 2009, 11:31 PM

Hi Rumen,

You're my hero. It works great!

Thank you so much for your help!

Tags
Editor
Asked by
Jeff
Top achievements
Rank 1
Answers by
Rumen
Telerik team
Jeff
Top achievements
Rank 1
Tervel
Telerik team
Georgi Tunev
Telerik team
Matt
Top achievements
Rank 2
John
Top achievements
Rank 1
Share this question
or