November Happy Hour will be moved to Thursday December 5th.

Custom Property Sample

Vote:
 
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
#15720
Jul 24, 2007 20:57
Vote:
 
Hi Pete, Have you looked in the help files? Try this link http://sdk.episerver.com/library/cms5/ and see if you get the answeres you need under the How to section. Regards
#16225
Jul 25, 2007 16:03
Vote:
 
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 ; } }
#16226
Jul 26, 2007 7:51
Vote:
 
Hi there, Thanks for the info but I'm actually looking for a complete sample (however simple). Is one not available? Cheers, Pete
#16227
Jul 29, 2007 1:04
Vote:
 
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).
#16228
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.