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

How can I add MediaPlayer in TemplateItem from code behind

3 Answers 10 Views
ImageGallery
This is a migrated thread and some comments may be shown as answers.
ghini
Top achievements
Rank 2
ghini asked on 13 Jul 2016, 04:50 PM

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

3 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 18 Jul 2016, 12:03 PM
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.
0
ghini
Top achievements
Rank 2
answered on 19 Jul 2016, 03:19 PM

Hi Maria,

can you post an example in VB?

Thanks a lot

0
Maria Ilieva
Telerik team
answered on 20 Jul 2016, 08:35 AM
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.
Tags
ImageGallery
Asked by
ghini
Top achievements
Rank 2
Answers by
Maria Ilieva
Telerik team
ghini
Top achievements
Rank 2
Share this question
or