AI OnAI Off
Can it be that you try this on already created block? EPiServer default values are only set when you create a new page / block.
Per Nergård was right. I was doing it on a block I already had created. Is it any way to say: if this property is blank, use this value?
Something like this can get you that behavior:
public virtual string Whatever
{
get { return this.GetPropertyValue(page => page.Whatever) ?? "a default value to return"; }
set { this.SetPropertyValue(page => page.Whatever, value); }
}
Nice, thanks! I tried to make custom setters and getters first, but I didn't use this.GetPropertyValue so it didn't work. Now it works!
EDIT: Would it be possible to set those defaults from episerver?
Hello!
I'm trying to set some default values for some properties in epi seerver 7.
I have this method in my block type:
public override void SetDefaultValues(ContentType contentType)
{
base.SetDefaultValues(contentType);
Title = "Default title";
}
But it isn't even called. I followed this guide:
http://world.episerver.com/Blogs/Alexander-Haneng/Dates/2012/9/How-to-define-default-values-for-pages-and-blocks-in-EPiServer-CMS-7/
Can anyone help?