AI OnAI Off
I have got it resolved by
var abc = pageData.GetValue("DisplayLabelId ");
if(abc != null)
{
FeatureName = CategoryHelper.GetCategoryDisplayName(Convert.ToInt16(abc));
}
This involved hardcoding the property name and conversion of object to int. Is there any better way than above?
I have a home page with some identical feature content blocks. Each block will have an url and featured name. The url should link to new page and featured name displayed should have
the some property value of the new page.
The featured content block has got the NavigationLink property as below:
public virtual PageReference NavigationLink { get; set; }
In the viewmodel of Featured block,
public string Link { get; set; }
public string FeatureName { get; set; }
public FeaturedContentViewModel(FeaturedContentBlock block)
{
if(block != null)
{
if(block.NavigationLink ! = null)
{
Link = block.NavigationLink.GetUrl();
//FeatureName should get the value from the page it's been set. PageData can be obtained by block.NavigationLink.GetPageData(), but how to check if property exists and get the value out of it
}
}
}
I could able to get the url and is working fine. But I want to render a property value of that new page and display in the block.
The new page has property
Public class General
{
[Required, UIHint(UIHints.SubCategorySelectSingle), Display(
Name = "Content label",
GroupName = EPiServerApplication.TabNames.MetaData,
Order = 20)]
[EditorDescriptor(EditorDescriptorType = typeof(CategoryIdSelectorSingle))]
[EditorDescriptorFilter(Name = ManagedLists.DisplayLabel)]
[SortDirection(Direction = SortDirection.Ascending)]
public virtual int DisplayLabelId { get; set; }
}
I want to get the value set in the new page for the property DisplayLabelId and display it in the featured block. As the user can link to any page, I want to
check if the property exists in the new page first and display if there 's any value in it.