'YouTube.Models.YouTube' does not contain a definition for 'Id'
I am new to Umbraco and razor syntax. I am sorry if this issue is already discussed.
I am using a partial view in which I want to display the videos I am using the following query to get videos:
@using YouTube.Models
@inherits Umbraco.Web.Mvc.UmbracoTemplatePage
@{
var homePage = CurrentPage.AncestorsOrSelf(1).First();
var lectureVideos = homePage.Descendants("videoLecture").Where("Visible");
}
@foreach (var lecture in lectureVideos)
{
var typedVideo = lecture.GetPropertyValue<YouTube>("youTubeVideos");
var videoId = typedVideo.Id;
var videoUrl = String.Format("https://www.youtube.com/watch?v={0}", videoId);
}
It gives the following error message:
'YouTube.Models.YouTube' does not contain a definition for 'Id'
Line 14: var typedVideo = lecture.GetPropertyValue<YouTube>("youTubeVideos");
Line 15: var videoId = typedVideo.Id;
Line 16: var videoUrl =String.Format("https://www.youtube.com/watch?v={0}", videoId);
Line 17: <p>@lecture.youTubeVideos</p>
can someone please help me to resolve this, or guide me how to display Youtube videos in this page.
Thanks for your reply, I have tried and resolved it, not sure if it's a better approach.
@foreach (var lecture in lectureVideos)
{
var VideoModel = lecture.GetPropertyValue<YouTube>("youTubeVideos");
var VideosList = VideoModel.GetEnumerator();
VideosList.MoveNext();
var typedVideo = VideosList.Current;
var videoId = typedVideo.Id;
var videoUrl = String.Format("https://www.youtube.com/watch?v={0}", videoId);
}
Please share if you have better solution for this, Thanks.
'YouTube.Models.YouTube' does not contain a definition for 'Id'
I am new to Umbraco and razor syntax. I am sorry if this issue is already discussed.
I am using a partial view in which I want to display the videos I am using the following query to get videos:
It gives the following error message:
'YouTube.Models.YouTube' does not contain a definition for 'Id'
can someone please help me to resolve this, or guide me how to display Youtube videos in this page.
Thanks in advance
When your casting to a YouTube object your calling for a ID on a IEnumerable. Trying calling .First() then getting the ID.
Thanks for your reply, I have tried and resolved it, not sure if it's a better approach.
Please share if you have better solution for this, Thanks.
is working on a reply...