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

Issue adding media template item in code behind

1 Answer 78 Views
ImageGallery
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Iron
Paul asked on 29 Nov 2016, 07:23 PM

I've followed the various steps in creating a custom video template item via the code behind. So for, the videos and thumbs load. However, the problem is that when I click next or a video from the gallery. It does a post back, the proper thumb is highlighted below, but the correct video doesn't show. If I start clicking around the proper videos do not show in their proper places.

Here is my code below:

Private Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Init
 
        For Each video As VideoClip In GetVideoCollection()
            Dim igti As New ImageGalleryTemplateItem()
            Dim template As New ImageGalleryContentTemplate(video)
            igti.ContentTemplate = template
            igti.ThumbnailUrl = video.Thumb
            RIG.Items.Add(igti)
        Next
         
    End Sub
 
Public Class VideoClip
        Private m_title As String
        Private m_videoID As String
        Private m_description As String
        Private m_thumb As String
 
        Public ReadOnly Property Title() As String
            Get
                Return Me.m_title
            End Get
        End Property
        Public ReadOnly Property VideoID() As String
            Get
                Return Me.m_videoID
            End Get
        End Property
        Public ReadOnly Property Description() As String
            Get
                Return Me.m_description
            End Get
        End Property
        Public ReadOnly Property Thumb() As String
            Get
                Return Me.m_thumb
            End Get
        End Property
 
        Public Sub New(title As String, videoID As String, description As String, thumb As String)
            Me.m_title = title
            Me.m_videoID = videoID
            Me.m_description = description
            Me.m_thumb = thumb
        End Sub
    End Class
 
    Private Function GetVideoCollection() As VideoClip()
        Dim clipsCollection As VideoClip() = New VideoClip(5) { _
            New VideoClip("Telerik UI for<br/> Windows 8 (Beta), UI", "http://www.youtube.com/watch?v=kCOH2ODKs0Q", "RadControls for" & _
                          "Windows 8 is the toolset for building Windows 8 apps that run on tablets and large screens " & _
                          "no matter if you are coming from the XAML or HTML/JavaScript world.", _
                          "/movies/thumbs/4b23b9b2-ee9d-4a85-97c6-006423dfd1b8.jpg"), _
            New VideoClip("Telerik Windows 8 UI Controls", "http://www.youtube.com/embed/yxzXFrlVPfc", "Create fascinating touch-enabled Windows" & _
                          "8 apps that users will love.", _
                          "/movies/thumbs/3f886145-c6b1-4341-a829-0a456b6eda08.jpg"), _
            New VideoClip("Building Windows Phone 7 Apps that Rock the Marketplace", "http://www.youtube.com/embed/bTGjwskU3LE", "RadControls for Windows" & _
                          "Phone is designed to speed up the development of windows phone apps and provide an array of controls.", _
                          "/movies/thumbs/3cdc9c12-3459-43e8-84bc-0f10bc1b6885.jpg"), _
            New VideoClip("Load Testing with Telerik Test Studio", "http://www.youtube.com/embed/8zPBJeBOER8", "See how you can set up your test environment," & _
                          "assign virtual users to your controller and agents and create your user scenarios using multiple channels.", _
                          "/movies/thumbs/d1f5a1ac-ace0-4dc8-8a34-bb87a5119826.jpg"), _
            New VideoClip("Telerik Software Testing Tool - Test Studio - Overview", "http://www.youtube.com/embed/4TGkGQonmy4", "With Test Studio you can create" & _
                          "functional web and desktop tests, performance tests and load tests with one easy tool.", _
                          "/movies/thumbs/c5a13e13-0332-4a51-8462-9300fc4b3027.jpg"), _
            New VideoClip("UI controls for building Windows Phone 7 apps.mp4", "http://www.youtube.com/embed/763LTx05-qA", "If you want to see the controls in" & _
                          "action make sure to check our ToDoLists video on youtube.", _
                          "/movies/thumbs/f5bf4181-b595-4516-9e5a-44daabe76137.jpg")}
 
        Return clipsCollection
    End Function
 
Private Class ImageGalleryContentTemplate
        Implements ITemplate
        Public Property BackgroundImage() As [String]
            Get
                Return m_BackgroundImage
            End Get
            Set(value As [String])
                m_BackgroundImage = Value
            End Set
        End Property
        Private m_BackgroundImage As [String]
        Public Property HTMLTemplate() As [String]
            Get
                Return m_HTMLTemplate
            End Get
            Set(value As [String])
                m_HTMLTemplate = Value
            End Set
        End Property
        Private m_HTMLTemplate As [String]
 
        Protected player As RadMediaPlayer
        Private video As VideoClip
 
        Public Sub New(video As VideoClip)
            Me.video = video
        End Sub
        Public Sub InstantiateIn(container As Control) Implements ITemplate.InstantiateIn
            player = New RadMediaPlayer()
            player.ID = "RadMediaPlayer1"
            player.RenderMode = RenderMode.Lightweight
            player.ToolBar.FullScreenButton.Style("display") = "none"
            player.Title = video.Title
            player.Source = video.VideoID
            player.TitleBar.ShareButton.Visible = False
            player.ToolBar.HDButton.Visible = False
            player.ToolBar.SubtitlesButton.Visible = False
 
            container.Controls.Add(player)
        End Sub
    End Class

 

Where am I going wrong with this?

1 Answer, 1 is accepted

Sort by
0
Viktor Tachev
Telerik team
answered on 02 Dec 2016, 09:52 AM
Hello Paul,

Would you try to create the entire RadImageGallery control in the code-behind using the Page_Init event and see how the behavior changes?

In case the issue persists please send us a runnable sample where the issue is replicated. Thus, we will be able to examine the behavior locally and look for its cause.

Regards,
Viktor Tachev
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
Tags
ImageGallery
Asked by
Paul
Top achievements
Rank 1
Iron
Answers by
Viktor Tachev
Telerik team
Share this question
or