Try our conversational search powered by Generative AI!

Hide property when creating block



How can I hide a property when creating a block, but showing the property on edit mode?

Also, is there a create content event? In that event, I want to set a property based on another property's value.

May 19, 2015 9:12

To clarify, there is no preview mode for this block.

May 19, 2015 9:15

If you are using form I think you can set the Editable attribute on the EPiServer:Property control that renders the property.

May 19, 2015 9:29

Using [Editable(false)] will make the the property not editable neither on create mode nor edit mode. It's only when creating the block I want to hide the property.

May 19, 2015 9:36

Sorry I missed that your block didn't have anya preview mode. 

May 19, 2015 10:16


If the property appears during block creation it's probably annotated with Required attribute. All properties with this attribute will be shown.

You could create you own validation rule (IValidate<T>), where you will check if the value is filled, but also if the PageLink.WorkId is not zero (it will be 0 for new pages). Then the required rule will be checked only during editing and the property won't be displayed in block craeting.

About second part of your question. You can subscribe to create event using code:

var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
//contentEvents.CreatingContent += ...
//contentEvents.CreatingContent += ...

May 19, 2015 11:48
* 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.