MediaObject

in namespace DotVVM.Framework.Controls.Bootstrap

Renders a clickable image inside the Bootstrap Media widget.

Usage & Scenarios

Renders Bootstrap Media Object.

https://getbootstrap.com/docs/3.3/components/#media

Sample 1: Basic Media Object

The MediaObject control has the HeaderText and Description properties which specify the header text and description of the media object.

The ImageUrl and AlternateText property sets the URL and the alt text of the image.

<bs:MediaObject ImageUrl="~/Images/person.png" 
  HeaderText="Basic Image" 
  Description="Simple Description" />

Sample 2: Media Object Templates

The MediaObject control supports templating for media content and body.

You can use the ImageTemplate property to define any content for the media section.

Also, instead of HeaderText and Description, you can use the ContentTemplate to specify your own content.

<bs:MediaObject>
  <ImageTemplate>
    <iframe width="300" height="180" src="https://www.youtube.com/embed/fJ9rUzIMcZQ" frameborder="0" allowfullscreen=""></iframe>
  </ImageTemplate>
  <ContentTemplate>
    <h1>Header</h1>
    <p>Description defined in content template.</p>
  </ContentTemplate>
</bs:MediaObject>
using DotVVM.Framework.ViewModel;

namespace DotvvmWeb.Views.Docs.Controls.bootstrap.Media.sample2
{
    public class ViewModel : DotvvmViewModelBase
    {
        public string Description { get; set; }= "This is media description.";
        public string HeaderText { get; set; } = "This is media header.";

    }
}

Sample 3: MediaList and Nested MediaObjects

By default, the MediaObject renders the <div> element, so you can use it independently.

However, if you place the MediaObject in the MediaList control, it will be automatically detect this and render as <li> element.

The MediaObject controls can be nested.

<bs:MediaList>

    <bs:MediaObject ImageUrl="~/Images/person.png" VerticalAlignment="Top" AlternateText="TEST">

        <ContentTemplate>
            <h4>Media object in list</h4>
            <p>Description in template</p>

            <bs:MediaObject ImageUrl="~/Images/person.png" VerticalAlignment="Top" AlternateText="TEST">
                <ContentTemplate>
                    <h4>Child</h4>
                    <p>Description of a child</p>

                    <bs:MediaObject HeaderText="Nested Media Object" Description="Simple description" VerticalAlignment="Top">
                        <ImageTemplate>
                            <iframe width="300" height="180" src="https://www.youtube.com/embed/fJ9rUzIMcZQ" frameborder="0" allowfullscreen=""></iframe>
                        </ImageTemplate>
                    </bs:MediaObject>

                </ContentTemplate>

            </bs:MediaObject>
        </ContentTemplate>

    </bs:MediaObject>

    <bs:MediaObject ImageUrl="~/Images/person.png" VerticalAlignment="Top" AlternateText="TEST" />

</bs:MediaList>

Properties

Name Type Description Notes Default Value
property icon AlternateText String Gets or sets the alternate text of the image.
attribute
inner element
static value
bindable
default
null
property icon Attributes Dictionary<String,Object>
attribute
inner element
static value
bindable
default
null
property icon ClientIDMode ClientIDMode Gets or sets the client ID generation algorithm.
attribute
inner element
static value
bindable
default
Static
property icon ContentTemplate ITemplate Gets or sets the content inside the Media object. Use this property if you don't need the default template.
attribute
inner element
static value
bindable
default
null
property icon DataContext Object Gets or sets a data context for the control and its children. All value and command bindings are evaluated in context of this value.
attribute
inner element
static value
bindable
default
null
property icon Description String Gets or sets the description text in the default content template. Do not use this property in combination with the ContentTemplate property.
attribute
inner element
static value
bindable
default
null
property icon HeaderText String Gets or sets the header text in the default content template. Do not use this property in combination with the ContentTemplate property.
attribute
inner element
static value
bindable
default
null
property icon Height String Gets or sets the height of the image.
attribute
inner element
static value
bindable
default
null
property icon HorizontalAlignment MediaPositionHorizontal Gets or sets the horizontal alignment of the image.
attribute
inner element
static value
bindable
default
Left
property icon ID String Gets or sets the unique control ID.
attribute
inner element
static value
bindable
default
null
property icon ImageTemplate ITemplate Gets or sets custom content instead of image.
attribute
inner element
static value
bindable
default
null
property icon ImageUrl String Gets or sets the URL of the image.
attribute
inner element
static value
bindable
default
null
property icon InnerText String Gets or sets the inner text of the HTML element.
attribute
inner element
static value
bindable
default
null
property icon NavigateUrl String Gets or sets the URL of the hyperlink.
attribute
inner element
static value
bindable
default
null
property icon RouteName String Gets or sets the name of the route which will be used to generate the URL.
attribute
inner element
static value
bindable
default
null
property icon UrlSuffix String Gets or sets the suffix that will be appended to the generated URL.
attribute
inner element
static value
bindable
default
null
property icon VerticalAlignment MediaPositionVertical Gets or sets the vertical alignment of the image.
attribute
inner element
static value
bindable
default
Middle
property icon Visible Boolean Gets or sets whether the control is visible.
attribute
inner element
static value
bindable
default
True
property icon Width String Gets or sets the width of the image.
attribute
inner element
static value
bindable
default
null

HTML produced by the control