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

19 posts, 0 answers
  1. gao
    gao avatar
    6 posts
    Member since:
    Nov 2010

    Posted 30 Sep 2011 Link to this post

    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 .
  2. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 04 Oct 2011 Link to this post

    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 >>

  3. DevCraft banner
  4. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 16 Nov 2011 Link to this post

    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
  5. Iva Toteva
    Admin
    Iva Toteva avatar
    1319 posts

    Posted 21 Nov 2011 Link to this post

    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 >>

  6. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 21 Nov 2011 Link to this post

    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
  7. Qloud Pty Ltd
    Qloud Pty Ltd avatar
    17 posts
    Member since:
    Sep 2011

    Posted 20 Dec 2011 Link to this post

    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

  8. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 22 Dec 2011 Link to this post

    Hello Rama,

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

    ~ Dave
  9. Boby
    Admin
    Boby avatar
    595 posts

    Posted 23 Dec 2011 Link to this post

    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 >>

  10. Qloud Pty Ltd
    Qloud Pty Ltd avatar
    17 posts
    Member since:
    Sep 2011

    Posted 23 Dec 2011 Link to this post

    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
  11. Qloud Pty Ltd
    Qloud Pty Ltd avatar
    17 posts
    Member since:
    Sep 2011

    Posted 23 Dec 2011 Link to this post

    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

  12. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 24 Dec 2011 Link to this post

    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
  13. Boby
    Admin
    Boby avatar
    595 posts

    Posted 28 Dec 2011 Link to this post

    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 >>

  14. Qloud Pty Ltd
    Qloud Pty Ltd avatar
    17 posts
    Member since:
    Sep 2011

    Posted 02 Jan 2012 Link to this post

    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

  15. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 02 Jan 2012 Link to this post

    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
  16. yu weng
    yu weng avatar
    2 posts
    Member since:
    Nov 2009

    Posted 04 Jan 2012 Link to this post

    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

  17. Qloud Pty Ltd
    Qloud Pty Ltd avatar
    17 posts
    Member since:
    Sep 2011

    Posted 28 Jan 2012 Link to this post

    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
  18. Qloud Pty Ltd
    Qloud Pty Ltd avatar
    17 posts
    Member since:
    Sep 2011

    Posted 28 Jan 2012 Link to this post

    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
  19. Raji
    Raji avatar
    56 posts
    Member since:
    Jul 2011

    Posted 18 Apr 2013 Link to this post

    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
     
  20. Dave Navarro
    Dave Navarro avatar
    150 posts
    Member since:
    Jul 2005

    Posted 20 Apr 2013 Link to this post

    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

Back to Top
DevCraft banner