Plugin: PropertyString and CreateChildControls

Vote:
 
I got warning why migrating PropertyString plugin from 4.61 to 5.1: 'EPiServer.Core.PropertyData.CreateChildControls(string, System.Web.UI.Control)' is obsolete: 'CreateChildControls is no longer used. Use CreatePropertyDataControl to create a control instead.' But I cannot find CreatePropertyDataControl in Epi5 namespaces, in SDK doc nor using reflector. What should I do? Also, there are warnings when overriding CreateChildControls method, that it is obsolete. How should be plugins implemented now?
#15891
Nov 22, 2007 18:06
Vote:
 
Properties has been rewritten in EPiServer CMS 5. There is a sample in the SDK under Developers Guide/Web Controls/Property Types
#16581
Nov 22, 2007 20:30
Vote:
 
For some reason I have problem implementing the sample code. I do exact copy'n'paste of the public class PropertyLongStringControlAdapter : PropertyDataControlAdapter in the example. Compile, and then go to admin and create custom property. Then I add that custom property to some page or as a dynamic property. But when I go to edit and try to display it in edit mode to set value I get: Server Error in '/' Application. -------------------------------------------------------------------------------- Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace: [NullReferenceException: Object reference not set to an instance of an object.] EPiServer.DataAccess.DynamicPropertiesDB.Load(PageReference pageLink) +1219 EPiServer.DataAbstraction.DynamicProperty.ListForPage(PageReference pageLink) +95 EPiServer.UI.Edit.EditDynProp.OnInit(EventArgs e) +43 System.Web.UI.Control.InitRecursive(Control namingContainer) +321 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +692 Note that when I start the solution in debug mode (F5), none of the breakpoints ever gets hit within the property code.
#16582
Nov 27, 2007 16:28
Vote:
 
Hi! The sample code you seem to have used is code that shows how to create a control adapter. This is used to override an existing control and is registered in the file AdapterMappings.browser. Below is a code sample on how to get a basic property control up and runnig. I would suggest that you look on the different base classes in the namespace EPiServer.Web.PropertyControls as they have functionality to setup basic input types. Heres the example: using System; using System.Data; using System.Configuration; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using EPiServer.Web.PropertyControls; using EPiServer.Core; namespace EPiServer.Test { public class MyCustomProperty : PropertyString { public override IPropertyControl CreatePropertyControl() { return new MyCustomPropertyControl(); } } public class MyCustomPropertyControl : PropertyStringControl { private TextBox _input1; public TextBox Input1 { get { return _input1; } set { _input1 = value; } } public override void CreateEditControls() { Input1 = new TextBox(); Input1.Text = Properties[Name].Value as string; Controls.Add(Input1); } public override void ApplyEditChanges() { SetValue(Input1.Text, Properties[Name]); } } }
#16583
Dec 06, 2007 15:04
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.