18 Answers, 1 is accepted
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.
Iva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
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
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).
Iva Toteva
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
I will review the link you sent and refer to my support ticket for the remainder of this issue.
Thanks!
~ Dave
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
What type of file are you attempting to load? Also, are you attempting to load it from the server?
~ Dave
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 >>
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
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
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
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 >>
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
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
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
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
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
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
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