How can I add MediaPlayer in TemplateItem from code behind

4 posts, 0 answers
  1. ghini
    ghini avatar
    25 posts
    Member since:
    Sep 2012

    Posted 13 Jul Link to this post

    Hi to all,

    I want to add images and videos to ImageGallery.

    I've read the article https://demos.telerik.com/aspnet-ajax/image-gallery/examples/functionality/templates/defaultcs.aspx
    but I have to add videos from code behind in VB.
    Can anyone tell me how?

    Thanks

  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 18 Jul Link to this post

    Hi Fabrizio,

    Try using the approach below:

    class ImageGalleryContentTemplate : ITemplate
        {
            public String BackgroundImage { get; set; }
            public String HTMLTemplate { get; set; }
     
     
            public void InstantiateIn(Control container)
            {
                container.Controls.Add(new RadMediaPlayer());
            }
        }
     
        protected void Page_Init(object sender, EventArgs e)
        {
     
            
            ImageGalleryTemplateItem igti = new ImageGalleryTemplateItem();
            ImageGalleryContentTemplate template = new ImageGalleryContentTemplate();
            igti.ContentTemplate = template;
            RIG.Items.Add(igti);
     
        }

    I hope this helps.

    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. ghini
    ghini avatar
    25 posts
    Member since:
    Sep 2012

    Posted 19 Jul in reply to Maria Ilieva Link to this post

    Hi Maria,

    can you post an example in VB?

    Thanks a lot

  5. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 20 Jul Link to this post

    Hi,

    Find the VB code below:
    Private Class ImageGalleryContentTemplate
        Implements ITemplate
        Public Property BackgroundImage() As [String]
            Get
                Return m_BackgroundImage
            End Get
            Set
                m_BackgroundImage = Value
            End Set
        End Property
        Private m_BackgroundImage As [String]
        Public Property HTMLTemplate() As [String]
            Get
                Return m_HTMLTemplate
            End Get
            Set
                m_HTMLTemplate = Value
            End Set
        End Property
        Private m_HTMLTemplate As [String]
     
     
        Public Sub InstantiateIn(container As Control)
            container.Controls.Add(New RadMediaPlayer())
        End Sub
    End Class
     
    Protected Sub Page_Init(sender As Object, e As EventArgs)
     
     
        Dim igti As New ImageGalleryTemplateItem()
        Dim template As New ImageGalleryContentTemplate()
        igti.ContentTemplate = template
        RIG.Items.Add(igti)
     
    End Sub


    Regards,
    Maria Ilieva
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top