Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Make property read-only in Editmode

Vote:
 

Is there a way to make a property read-only in edit mode? We have pages created from another source and some of the values is not to be changed in EPiServer but they must be visible to the editor. So to hide it in edit mode is not enough since it should be visible but editable.

#74065
Aug 20, 2013 11:47
Vote:
 

According to the documentation you should be able to set either the Editable or ReadOnly attributes to control this (http://world.episerver.com/Documentation/Items/Developers-Guide/EPiServer-Framework/7/User-Interface/Object-Editing/Object-Editing/).

#74068
Aug 20, 2013 12:52
Vote:
 

Yes, can't believe I missed that...

#74070
Aug 20, 2013 13:12
Vote:
 

Is this possible in CMS 6 R2? I can't find anywhere how to accomplish this.

#76088
Oct 16, 2013 16:54
Vote:
 

Persyl: I don't think so. I'ts possible to accomplish with a custom property though.

#76094
Oct 16, 2013 17:45
Ted
Vote:
 

What I've done in CMS 6 is to create a custom property type called PropertyReadOnlyString inheriting PropertyString and then simply add a "disabled" attribute when the edit control is created. Same can be applied to PropertyLongString, PropertyNumber, etc.

#76100
Edited, Oct 16, 2013 23:31
Vote:
 

I did the same solution as Ted.

This is what you need to do in the CreateEditControls() method of the Control class.

public override void CreateEditControls()
{
this.EditControl.Attributes.Add("disabled", "disabled");
}

 

#76113
Oct 17, 2013 8:41
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* 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.