Add MediaPlayer in TemplateItem from code behind (images AND videos)

2 posts, 0 answers
  1. HMPSOLBB
    HMPSOLBB avatar
    15 posts
    Member since:
    Mar 2012

    Posted 25 Jul Link to this post

    I found this post http://www.telerik.com/forums/how-can-i-add-mediaplayer-in-templateitem-from-code-behind#LMcMKDN-1kyBzTiLR_Sa2A whitch works fine if iprvide only video files. Now i got a db with images and videos and try to put them together in a ImageGallery. is there a way to publish such a Gellery with a mixture of images and videos. For images i don´t need a template bit für the videos i will do so. All the data are providet by a datatable in code behind.

     

    Anyone gots some hints for me?

     

    regs

    Oliver

     

     

     

  2. Viktor Tachev
    Admin
    Viktor Tachev avatar
    1488 posts

    Posted 28 Jul Link to this post

    Hi Oliver,

    You can add additional items to the RadImageGallery the same way as the template item.


    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)
    {
        ImageGalleryItem igItem = new ImageGalleryItem();
        igItem.ImageUrl = "~/Images/ImageGallery/image1.jpg";
        RIG.Items.Add(igItem);
     
        ImageGalleryTemplateItem igti = new ImageGalleryTemplateItem();
        ImageGalleryContentTemplate template = new ImageGalleryContentTemplate();
        igti.ContentTemplate = template;
        RIG.Items.Add(igti);
     
    }


    In your scenario you can iterate through the items of the DataTable and add the necessary items to the ImageGallery.


    Regards,
    Viktor Tachev
    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
Back to Top