Inserting an image in the RadRichtextbox

4 posts, 0 answers
  1. Deepthi
    Deepthi avatar
    11 posts
    Member since:
    Jan 2011

    Posted 07 Jan 2011 Link to this post

    Hi ,
    I want to insert an image in the RadRichtextbox by giving absolute url like http://xxx/image1.jpg (similar to insert image functionality  in the AjaxRadEditor) . Is there any option for this?

    Deepthi P
  2. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 10 Jan 2011 Link to this post

    Hello Deepthi,

     To your  question, ImageInline does support creation of images from an absolute URI. The site in which the image is hosted, however, has to allow that in its cross-domain policy file. A simple example (for a site that has a permissive cross-domain policy) is provided below:

    ImageInline imageInline = new ImageInline()
        UriSource = new Uri(url, UriKind.Absolute),
        Width = 150,
        Height = 150,

    In case the site does not have a permissive policy, you can try:

    Image image = new Image()
        Source = new BitmapImage(newUri(url, UriKind.Absolute)),
        Width = 150,
        Height = 150,
    InlineUIContainer imageContainer = new InlineUIContainer(image, newSize(150, 150));

    You can read more about Silverlights' security policy system here.

    Best wishes,
    the Telerik team
    Let us know about your Windows Phone 7 application built with RadControls and we will help you promote it. Learn more>>
  3. DevCraft banner
  4. Pablo
    Pablo avatar
    7 posts
    Member since:
    May 2013

    Posted 27 Aug 2013 Link to this post

    I'm building an OOB Silverlight app and I need to insert local file images programmatically but I the code sample you posted doesn't work, please help.
  5. Iva Toteva
    Iva Toteva avatar
    1319 posts

    Posted 28 Aug 2013 Link to this post

    Hi Pablo,

    The approaches shown below illustrate the inserting of images from an absolute web Uri.

    In order to be able to retrieve an image from the local machine, a slightly different approach should be used. First of all, the application must require elevated trust when running outside of the browser (see attached screenshot).

    Then, you could access a file using an absolute URI such as "C:/Users/itoteva.TELERIK/Pictures/tick.png". However, ImageInline does not handle automatically URIs in this format, so you should obtain the image yourself and use it to instantiate an ImageInline. This can be done like this:

    BitmapImage bitmapImage = new BitmapImage(new Uri(url, UriKind.Absolute));
    bitmapImage.CreateOptions = BitmapCreateOptions.None;
    bitmapImage.ImageOpened += (s, a) =>
        WriteableBitmap writableBitmap = new WriteableBitmap((BitmapImage)s);
        ImageInline image = new ImageInline(writableBitmap);

    I hope this helps.

    Iva Toteva
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
Back to Top