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

Image in Rad Rich text box

6 Answers 355 Views
RichTextBox
This is a migrated thread and some comments may be shown as answers.
Sandip
Top achievements
Rank 1
Sandip asked on 17 Feb 2011, 08:14 PM
Telerik Rad Rich Text box can display Text embedded in HTML but not the Image. 






<telerik:RadRichTextBox Grid.Row="7" x:Name="editor" Margin="24,55,22,13" Width="740" Height="200" IsSpellCheckingEnabled="True" AllowDrop="True" IsReadOnly="false">
            <telerik:RadRichTextBox.Resources>
                <telerikDocumentsHTML:HtmlDataProvider x:Key="HtmlProvider" RichTextBox="{Binding ElementName=editor}" Html="{Binding Body, Mode=TwoWay}" />
            </telerik:RadRichTextBox.Resources>
        </telerik:RadRichTextBox>

I am trying to implement the code mentioned above for Rad Rich TextBox. The textbox shows the text value emmbeded in the html. But the problem it cannot show if the html contains a image source. The HTML tried..... <table><tr><td>Test Image</td></tr><tr><td><img src="c:\\20519a.jpg" ></img></td></tr></table> Can the image be shown in Rad Rich text box?

6 Answers, 1 is accepted

Sort by
0
Ivailo Karamanolev
Telerik team
answered on 22 Feb 2011, 11:33 AM
Hi Sandip,

Please note the source of the image -
c:\\20519a.jpg
. This is a local file on your computer, and besides being unavailable anywhere else, it's outside the Silverlight security sandbox and therefore not rendered in RadRichTextBox. For images to be visible in RadRichTextBox when you load an HTML source file, they should be either embedded (base64 encoded) or with an URI either within the same domain as the Silverlight application or on a domain with a permissive cross-domain policy.
Let us know if we can assist you any further.

Greetings,
Ivailo
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
David
Top achievements
Rank 1
answered on 19 Nov 2011, 04:35 PM
Hello I would like to allow my users to embed images, tables, and if possible files into RadRichTextbox. Can you provide some sample code on how to do this. Note I don't mean links to image files on a server. I mean actual images directly into the control, just like pasting text. Thanks.
0
Iva Toteva
Telerik team
answered on 23 Nov 2011, 02:14 PM
Hello David,

RadRichTextBox for Silverlight/WPF is quite different from RadEditor for ASP.NET. It runs on the client and the images are inserted as instances of ImageInline. These elements are always embedded in the document, i.e. you cannot show an image in RadRichTextBox in any other way than embedding it in the document. The RichTextBox does not have an Html property like the ASP.NET editor and only exports its document on demand (using format or data providers).
You can preview our online demo and see how the InsertPictureCommand, which the button in RadRichTextBoxRibbonUI is bound to, works for inserting an image that the client chooses using the OpenFileDialog. There are also methods in RadRichTextBox's API for inserting Images (ImageInline inherits Inline - see here):

public void InsertImage(Stream imageStream, string extension)
public void InsertInline(Inline inline)

However, pasting images in Silverlight can only be done between two RadRichTextBoxes, as Silverlight's clipboard supports only plain text.
I hope this helps.

Kind regards,
Iva Toteva
the Telerik team

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

0
Srivat
Top achievements
Rank 1
answered on 21 Dec 2011, 11:11 PM
Hello,

I am working on an out-of-browser (with trusted level) silverlight app to display XHTML.
I have all the XHTML in "My Documents". In spite of that, the text box does not display images. I have the sample XHTML below.

"image/cover.jpg" is in a sub directory of the XHTML file

Thanks
Sri
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<head>
<title>Sample Title</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link href="LD.css" rel="stylesheet" type="text/css"/>
</head>
<body style="background-color: #000007; margin: 0.00em;">
<div id="coverpage">
<p class="center">Testing 1<img src="image/cover.jpg" height="100%" alt="cover" /> Testing 2</p>
</div>
<p class="breakhere"></p>
</body>
</html>


0
Boby
Telerik team
answered on 26 Dec 2011, 02:52 PM
Hi Srivat,
In out-of-browser mode, relative URIs are resolved using application's site of origin as base URI, so you have to have 'image/cover.jpg' published there. You can also choose to use images embedded directly in the HTML as base64-encoded strings.

All the best,
Boby
the Telerik team

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

0
yu weng
Top achievements
Rank 1
answered on 31 Dec 2011, 04:05 AM

I use RadRichTextBox for silverlight to insert image info for view,the data can be insert sccussful,but when I get the same data from MysqlDB for edit,the images can't be display, can you tell me why?   help.

Flowing is test code :

IDocumentFormatProvider 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 contains image,but view in radRichTextBox2, not display image.

Thanks,
Wendy. 

Tags
RichTextBox
Asked by
Sandip
Top achievements
Rank 1
Answers by
Ivailo Karamanolev
Telerik team
David
Top achievements
Rank 1
Iva Toteva
Telerik team
Srivat
Top achievements
Rank 1
Boby
Telerik team
yu weng
Top achievements
Rank 1
Share this question
or