November Happy Hour will be moved to Thursday December 5th.

Override property with IgnoreAttribute

Vote:
 

In EPiServer 7.0 I can do:

public abstract class SitePageData : PageData
{
    [Ignore]
    public virtual string Heading
    {
        get { return this.Name; }
        set { throw new NotImplementedException(); }
    }
}

public class InformationPage : SitePageData
{
    [CultureSpecific]
    [Display(GroupName = SystemTabNames.Content, Order = 10)]
    public override string Heading
    {
        get
        {
            string heading = this.GetPropertyValue(content => content.Heading);

            return !string.IsNullOrEmpty(heading) ? heading : this.Name;
        }
        set { this.SetPropertyValue(content => content.Heading, value);
       }
    }
}
But I can not do this in 7.5. It looks like the IgnoreAttribute cant be overridden. If I look at the InformationPage in Admin-mode the property "Heading" is missing. Should I be able to do like this? Or how should I solve it?

Regards Hans
#86612
May 26, 2014 16:49
Vote:
 

Haven't used myself. What about Scaffold(false) ?

#86658
May 27, 2014 21:03
Vote:
 

Try using 

public new virtual string Heading {...}
#86666
May 28, 2014 9:55
Vote:
 

I would suggest that you take another approach on your class inheritance..

And if you need to have fallback data on values it's mostly a better approach to let the rendering do this instead of adding this to the model/pagetype.

#86687
May 28, 2014 13:51
Vote:
 

Valdis Iljuconoks

ScaffoldColumn(false) doesn't stop EPiServer serialize the property I think

#86722
May 29, 2014 1:48
Vote:
 

Hi, and thanks all

Sorry for not answering earlier, been busy busy busy doing nothing at all... ;-)

First I solved it like this (as Per also have suggested)

public abstract class SitePageData : PageData
{
    public virtual string Heading
    {
        get
        {
            string heading = this.GetPropertyValue(content => content.Heading);
 
            return !string.IsNullOrEmpty(heading) ? heading : this.Name;
        }
    }
}
 
public class InformationPage : SitePageData
{
    [CultureSpecific]
    [Display(GroupName = SystemTabNames.Content, Order = 10)]
    public new virtual string Heading
    {
	get { return base.NavigationItemName; }
	set { this.SetPropertyValue(content => content.NavigationItemName, value); }
    }
}

But I want to avoid overriding with "new". So I will try "ScaffoldColumn", didnt know about that attribute. I will also consideer what Alf says, I agree you have a point there.

Regards Hans

#86969
Jun 05, 2014 12:17
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.