Search Results for

    Show / Hide Table of Contents

    Anchor Renderer

    The AnchorRenderer will render a link (a tag) to a media item.

    var media = client.Load<Media>(35)
        .Single();
    var context = new RenderContext(media);
    
    //You can of course force the anchor renderer if you would like to
    //context.RendererId = AnchorRenderer.RendererId;
    
    var html = MediaRenderer.Render(context);
    

    The following context values can be used to control the behavior of the anchor. (In addition to the generic context keys that can be set to all renderers.)

    Url

    Translated to the href attribute of the a element.

    Default is the url to the media item

    context.Set(ContextKey.Url, "https://my.site.com");
    

    Target

    Translated to the target attribute of the a element.

    Default is not set

    context.Set(ContextKey.Target,"_blank");
    

    Name

    Translated to the text content of the a element.

    Default is the name of the Media item.

    context.Set(ContextKey.Name, "My link");
    
    In This Article
    Back to top (c) Meriworks 2002-2022