AI OnAI Off
Hello Juan,
Technically you could define NewProperty like this:
[Display(GroupName = SystemTabNames.Content)] public virtual string NewProperty { get { return this.GetPropertyValue(page => page.NewProperty) ?? "Hello world"; } set { this.SetPropertyValue(page => page.NewProperty, value); } }
But then "Hello world" will be a fallback value, i.e. NewProperty will never be null.
In All Properties view, however, the text box will be empty if an editor did not specify the value.
Thank you @Dejan Caric
We don't have a way to not be empty in the "All Properties view"?
In that case I would hook up to the ContentSaving or ContentPublishing event and set the value. Keep in mind to describe this functionality for the editors as they might be confused in the beginning.
http://jondjones.com/how-to-hook-into-the-episerver-cms-events-pipeline/
Hello All,
I'm wondering how I can set the default value of a new property that I added to an existent block. I know that I can override the method "SetDefaultValues" but this will only work when the editor create a new block.
What a about the block that were already created?
In the code Bellow "NewProperty" is the property added to the block "MyExistenBlock" and I want to give a default value "Hello World" even for the blocks already created in the BE of Episerver by the editors