Custom Property Sample

Hi Guys, I notice from the release notes that the way custom properties are created in version 5 has changed. With-out a code-sample its a little tricky to know where to start. Is one available and where can I download it from? Cheers Pete
Jul 24, 2007 20:57
Hi Pete, Have you looked in the help files? Try this link and see if you get the answeres you need under the How to section. Regards
Jul 25, 2007 16:03
This Code may help.. this property "CheckNonZeroValue" will checks the non zero value, if non zerovalues is assigned this will return 1 . private int _nonZeroval = 0; public int CheckNonZeroValue { get { if (_nonZeroval < 0) { return 1; } else { return _nonZeroval; } } set { _nonZeroval = value ; } }
Jul 26, 2007 7:51
Hi there, Thanks for the info but I'm actually looking for a complete sample (however simple). Is one not available? Cheers, Pete
Jul 29, 2007 1:04
Below is a simple codesample that demonstrates how to change the default behavior for built in properties using ASP.NET control adapters. The code will add a message beside the PageName property in editmode. using System; using System.Web.UI; using System.Web.UI.WebControls; using EPiServer.Web.PropertyControls; using EPiServer.Web.PropertyControls.Adapters; namespace EPiServerDemo.PropertyTypes { public class PropertyStringControlAdapter : PropertyDataControlAdapter { private const string PageNamePropertyName = "PageName"; private Label lblMessage; public override void CreateEditControls() { base.CreateEditControls(); if (this.Name.Equals(PageNamePropertyName)) { //Adding a message beside the PageName property lblMessage = new Label(); lblMessage.Text = "Note: Please keep PageName short"; lblMessage.Font.Italic = true; Control.Controls.Add(new LiteralControl(" ")); Control.Controls.Add(lblMessage); } } } } You also need to add the following to your AdapterMappings.browser file If you want to override the complete behavior of the control (not just adding a message), you need to create and add the control yourself (remove call to base.CreateEditControls()) and override ApplyChanges() to save the value (see SDK for sample code).
Aug 07, 2007 12:47
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.