November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
No one?
If I inherit the IPropertyControlFactory instead of PropertyString - I'll need to implement some methods. How should they look like?
public class RightColumnSortorder_Property : IPropertyControlFactory { public override IPropertyControl CreatePropertyControl() { return (IPropertyControl)BuildManager.CreateInstanceFromVirtualPath("~/Templates/FMV/Util/RightColumnSortorder_PropertyControl.ascx", typeof(RightColumnSortorder_PropertyControl)); } public IPropertyControl CreatePropertyControl(PropertyData propertyData) { throw new NotImplementedException(); } public bool IsRegistered<TPropertyData>() where TPropertyData : PropertyData { throw new NotImplementedException(); } public IPropertyControlFactory Register<TPropertyData>(Func<IPropertyControl> controlFactory) where TPropertyData : PropertyData { throw new NotImplementedException(); } public IPropertyControlFactory Register<TPropertyData, TPropertyControl>() where TPropertyData : PropertyData where TPropertyControl : IPropertyControl { throw new NotImplementedException(); } public IPropertyControlFactory Unregister<TPropertyData>() where TPropertyData : PropertyData { throw new NotImplementedException(); } }
I've two custom properties that are "simple". But I also have one more advanced property that overrides several methods that seems to be missing in IPropertyControlFactory like: ParseToObject(), SetDefaultValue() and so on.
Hi
You could register your property control from an IInitializableModule like:
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))] public class PropertyControlRegisterModule : IInitializableModule { public void Initialize(InitializationEngine context) { context.Locate.Advanced.GetInstance<IPropertyControlFactory>().Register<RightColumnSortorder_Property>(() => (IPropertyControl)BuildManager.CreateInstanceFromVirtualPath("~/Templates/Util/RightColumnSortorder_PropertyControl.ascx", typeof(RightColumnSortorder_PropertyControl))); } public void Uninitialize(InitializationEngine context) { } }
Adding the IInitializableModule and removing CreatePropertyControl() I was able to build the project, but my custom properties ends up as a regular textbox and a datepicker in edit-mode. So no success this far :(
[InitializableModule] [ModuleDependency(typeof(EPiServer.Web.InitializationModule))] public class PropertyControlRegisterModule : IInitializableModule { public void Initialize(InitializationEngine context) { //RightColumnSortorder_Property context.Locate.Advanced.GetInstance<IPropertyControlFactory>().Register<RightColumnSortorder_Property>(() => (IPropertyControl)BuildManager.CreateInstanceFromVirtualPath("~/Templates/Util/RightColumnSortorder_PropertyControl.ascx", typeof(RightColumnSortorder_PropertyControl))); //ArchiveDate_Property context.Locate.Advanced.GetInstance<IPropertyControlFactory>().Register<ArchiveDate_Property>(() => new ArchiveDate_PropertyControl()); } public void Uninitialize(InitializationEngine context) { } }
The RightColumnSortorder_PropertyControl.ascx looks looks like this. Implementing IPropertyControl
public partial class RightColumnSortorder_PropertyControl : UserControlBase, IPropertyControl { //... }
And the ArchiveDate_PropertyControl looks like:
public class ArchiveDate_PropertyControl : EPiServer.Web.PropertyControls.PropertyDateControl { //... }
Something else I need to add/change?
The edit mode is not rendered through WebForms but from a javascript framework. So to customize the edit experience in edit mode you would need to do something like described in
https://world.episerver.com/documentation/developer-guides/CMS/editing/Registering-a-custom-editor/
Ok, I was affraid of that. Good point about edit mode and WebForms. Thanks
How to implement IPropertyControlFactory Methods in episerver 11? Previously I can override methods inherited from PropertyString Class but now how to do it in upgraded version?
You are not supposed to implement IPropertyControlFactory, instead you register a custom factory method for your custom property. In example below (more detail is in previous post in this thread) a web control ArchiveDate_PropertyControl is registered for custom property ArchivedDate_Property
context.Locate.Advanced.GetInstance<IPropertyControlFactory>().Register<ArchiveDate_Property>(() => new ArchiveDate_PropertyControl());
According to the breaking changes for EPiServer 11:
CreatePropertyControl has been removed from PropertyData. Use IPropertyControlFactory instead to register and create controls for PropertyData types.
But how do I do this in the following code?