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

How to use Rad Editor edit a document and save in the server

18 Answers 489 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
gao
Top achievements
Rank 1
gao asked on 30 Sep 2011, 07:56 AM
How to use Rad Editor edit a document and save in  the server ?

And also, how to use read-only Rad Editor to load .docx document? The example only shows the .xaml document .

18 Answers, 1 is accepted

Sort by
0
Iva Toteva
Telerik team
answered on 04 Oct 2011, 02:19 PM
Hello Gao,

Please find attached two demo projects showing how the content of the document can be persisted in XAML and docx formats. With XAML, you can use a DataProvider to bind the content of the document and with docx you can use the FormatProvider to import and export the document whenever necessary. More information on the existing DataProviders that can be used to bind the document can be found here, whereas the use of FormatProviders is described in this article.
When it comes to showing the documents without being able to modify their contents, this can be achieved by setting the IsReadOnly property of RadRichTextBox to True.

Regards,
Iva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Dave Navarro
Top achievements
Rank 2
answered on 17 Nov 2011, 12:06 AM
Hello everyone,

I'm trying to understand how this works too. I want to work with .docx files and they're located on the server in the App_Data folder. I tried reviewing the code examples but it's still confusing to me.

Here's another example I found but it doesn't address the issue of getting to the server to return a stream;

public RadDocument ImportDocx()
{
    RadDocument document = null;
    IDocumentFormatProvider provider = new DocxFormatProvider();
    OpenFileDialog openDialog = new OpenFileDialog();
    openDialog.Filter = "Documents|*.docx";
    openDialog.Multiselect = false;
    bool? dialogResult = openDialog.ShowDialog();
    if (dialogResult == true)
    {
        using (FileStream stream = openDialog.File.OpenRead())
        {
            document = provider.Import(stream);
        }
    }
    return document;
}

Many thanks in advance,

~ Dave
0
Iva Toteva
Telerik team
answered on 21 Nov 2011, 04:57 PM
Hi Dave,

The sample you have found opens uses the OpenFileDialog to select a file from the client machine, open a stream with the content of the file and load it uses DocxFormatProvider. All operations are performed on the client, so it is rather unrelated to the goal you wish to accomplish - loading a file from the server.
You can refer to MSDN for more information and walkthroughs on RIA services, which deal with the task of transferring information between the server (the ASP project) and the client (the Silverlight project).

Best wishes,
Iva Toteva
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Dave Navarro
Top achievements
Rank 2
answered on 21 Nov 2011, 11:15 PM
Hello and thanks for the reply.

I will review the link you sent and refer to my support ticket for the remainder of this issue.

Thanks!

~ Dave
0
Qloud Pty Ltd
Top achievements
Rank 1
answered on 20 Dec 2011, 01:36 PM

Hi,

I am getting warning and unable to run as it returns the error , when i am running the above sample files.

Please find the error details below.

Warning 1 The "CreateRiaClientFilesTask" task was not given a value for the required parameter "ClientFrameworkPath". DbExample

 

Regards
Rama

0
Dave Navarro
Top achievements
Rank 2
answered on 22 Dec 2011, 06:49 AM
Hello Rama,

What type of file are you attempting to load? Also, are you attempting to load it from the server?

~ Dave
0
Boby
Telerik team
answered on 23 Dec 2011, 06:21 PM
Hi Rama,
Could you please specify which is the demo you are trying to build and the version of the controls you are trying to build the demo against? Please verify that all Telerik assemblies you reference has the same version. It would help if you send us the complete error list, or the whole project (through a support ticket) if you modified it in any way.
Looking forward to your reply.

All the best,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Qloud Pty Ltd
Top achievements
Rank 1
answered on 24 Dec 2011, 12:49 AM
Dear Boby,

I've tried with the below attached files

RiaDataBindingXAML.zip
RiaPersistingInOpenXML.zip

Getting an error : Warning 1 The "CreateRiaClientFilesTask" task was not given a value for the required parameter "ClientFrameworkPath". DbExample

Regards
Rama
0
Qloud Pty Ltd
Top achievements
Rank 1
answered on 24 Dec 2011, 12:51 AM
Hi Dave,

Thank you for your reply.

Did you found any solution for loading document templates from the server  and merging with few data base fields in to the document  and save it in to the local database?

Regards
Rana

0
Dave Navarro
Top achievements
Rank 2
answered on 24 Dec 2011, 07:40 PM
Hello Rama,

Well, I did. With the help of Telerik support I was able to write up a solution that fit my needs.

My requirements were to;
1. Set the database path for each client dynamically
2. Open a .docx file from a server folder (App_Data) or any folder on any server
3. Load the .docx file into the Richtextbox for editing
4. Replace 'placeholder' text within the .docx file with text coming from the database
5. Save the .docx back to the server and overwrite the previous file
6. Clean up any temp files created during file transfer

Is this similar to what you're trying to accomplish? If so, which part are you having trouble with?

What parts do you have working?

~ Dave
0
Boby
Telerik team
answered on 28 Dec 2011, 10:47 AM
Hi Rama,
Can you try re-installing the Silverlight 4 Tools and Entity Framework?

All the best,
Boby
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Qloud Pty Ltd
Top achievements
Rank 1
answered on 02 Jan 2012, 06:30 AM
Dave,

Happy new Year

Thank you for your reply.

Yes, Almost Similar solution I am looking for. Coudl you please send me the sample for my reference.

Just find the attached file for detailed info.

Regards
Rama
rama@shoppersstop.com.au

0
Dave Navarro
Top achievements
Rank 2
answered on 02 Jan 2012, 08:08 AM
Hello Rama,

I've written quite a bit of code so help me to help you, please tell me which part is giving you trouble at the moment and we'll start there.

Thanks,

~ Dave
0
yu weng
Top achievements
Rank 1
answered on 04 Jan 2012, 10:43 AM

I have a problem for 3 days about RadrichtextBox. when i use radrichtextbox ,i can save the data(inclue images) into server db,but when i get the same data from database, but the data can be view right expect the images,the images can't display ,can you give me some help?
thanks.
here is a sample code:

XamlFormatProvider provider = new XamlFormatProvider();
            using (MemoryStream sStream = new MemoryStream())
            {
                  provider.Export(radRichTextBox1.Document,sStream);
                sStream.Seek(0,SeekOrigin.Begin);               
                radRichTextBox2.Document = provider.Import(sStream);             
            }

in the radRichTextBox1,insert a image.but when i get the data from  radRichTextBox1 by the above function, and view in  radRichTextBox2 it can't display images in radRichTextBox2.
why?
Thanks.
wendy

0
Qloud Pty Ltd
Top achievements
Rank 1
answered on 28 Jan 2012, 10:37 AM
To
Telerik Team,

Could someone please provide Mail Merge in Light Switch using data from tables  i.e Templates, Contacts  and finally save it in to the database.

http://demos.telerik.com/silverlight/#RichTextBox/MailMerge

Regards
Rama
0
Qloud Pty Ltd
Top achievements
Rank 1
answered on 28 Jan 2012, 10:44 AM
Dear Dave,

Yes, exactly I am looking like your solution.

Basically, every client has different templates loading from the server and they will merge with their customers data and saving file in to the database as a record.

Could you please send me the sample in LS VB?

Regards
Rama
0
Raji
Top achievements
Rank 1
answered on 18 Apr 2013, 06:35 PM
Hi Dave,

I have the same requirement as yours. I want to open a docx word document from server (any folder on the server) and then save it back to the same location on the server(overrite the same file). I want to open the docx file into the richtextbox for editing. Do I need to have .net 4.0 and silverlight 4.0 on the server. If you have a sample code on how to do this that would be really helpful. 

Thanks,
Raji
 
0
Dave Navarro
Top achievements
Rank 2
answered on 20 Apr 2013, 03:48 PM
Hello Raji,

With help from Telerik support, I implemented this method to load .docx files from the server.

private void importDocx()
{
    Uri url = new Uri("../AppData/Alpha/" + app.strServerName + "/Bravo/Charlie/" + app.strBinFilename + "", UriKind.RelativeOrAbsolute);
    WebClient wc = new WebClient();
    wc.OpenReadAsync(url);
    wc.OpenReadCompleted += (s, args) =>
    {
        if (args.Error == null)
        {
            try
            {
                IDocumentFormatProvider formatProvider = DocumentFormatProvidersManager.GetProviderByExtension(".docx");
                this.radRichTextBox1.Document = formatProvider.Import(args.Result);
            }
            catch
            {
                //Your error code can go here.
            }
        }
        else
        {
            //Your error code can go here.
        }
    };
}

I left the Uri in place so you could see how I pass in my variables and create "any" folder location on the server. Also, please note the folder named; AppData is NOT the same as App_Data. We developers do not have access to the App_Data folder with the WebClient method.

Of course, my requirements were to use the App_Data folder so I created some additional code to handle that.

This code snippet is however the method that does most of the work. Also, regarding your question about needing Silverlight 4 on the server. I was not required to do anything 'extra' to the server in order for this code to work.

One last note; I implemented this code when my project was using Silverlight 4. It has been upgraded to use Silverlight 5 and this code continues to work without any changes required.

I hope this helps,

~ Dave

Tags
RichTextBox
Asked by
gao
Top achievements
Rank 1
Answers by
Iva Toteva
Telerik team
Dave Navarro
Top achievements
Rank 2
Qloud Pty Ltd
Top achievements
Rank 1
Boby
Telerik team
yu weng
Top achievements
Rank 1
Raji
Top achievements
Rank 1
Share this question
or