Don't miss out Virtual Happy Hour today (April 26).
Try our conversational search powered by Generative AI!
AI OnAI Off
Don't miss out Virtual Happy Hour today (April 26).
Hi Tanvi,
You should use the AllowedType attribute to ContentArea.
[AllowedTypes(
AllowedTypes = new[] {typeof(CalloutBlock )})]
public virtual ContentArea MainContentArea { get; set; }
Then you can loop through the items and cast them to appropriate type and access their properties
@foreach (var item in Model.MainContent.FilteredItems.Select(x => x.GetContent()))
{
if (item is CalloutBlock calloutBlock)
{
@Html.PropertyFor(x => calloutBlock.Title)
}
else if (item is ParagraphBlock paragraphBlock)
{
@Html.PropertyFor(x => paragraphBlock.CopyTop)
}
}
I have a block and ContentArea property like below:
public class QuestionnaireBlock : BlockBase
{
[CultureSpecific]
[Display(Name = "Questions Content Area", GroupName = PropertyGroupNames.Content, Order = 10)]
public virtual ContentArea QuestionsContentArea { get; set; }
}
I place a block inside this QuestionsContentArea property as given below:
[CultureSpecific]
[Display(Name = "Question Text", GroupName = PropertyGroupNames.Content, Order = 10)]
public virtual string QuestionText { get; set; }
[CultureSpecific]
[Display(Name = "Items", GroupName = PropertyGroupNames.Content, Order = 20)]
[EditorDescriptor(EditorDescriptorType = typeof(AnswerListPropertyDescriptor))]
[ListItems(4)]
public virtual IList<QuestionnaireAnswerBlock> Answers { get; set; }
}
how do I get the values of the properties of the block placed inside a contentarea in my model of type QuestionnaireBlock in the controller class