Yes/No/Inherit

Vote:
 
I'll give 500 SEK (+ swedish VAT) to the first person who sends me code for a property plugin as described in this thread: http://www.episerver.com/templates/ForumItem____2459.aspx That is, a Yes/No/Inherit control based on Integer. I need it urgently for a project and I don't have the time to solve it. Contact me for details if you're interested. / Ted phone: 0704-67 84 58 (sweden) mailto:episerver4devforum@callander.se
#12352
Mar 25, 2008 18:34
Vote:
 
Good morning. Here you have the code for a dropdown. Add the values to the dropdown from the web.config or a xml-file. using System; using System.Web.UI; using System.Web.UI.WebControls; using EPiServer.Core; using System.Drawing; using System.ComponentModel; using EPiServer.PlugIn; namespace omnion { [PageDefinitionTypePlugIn] public class MyDropdownProperty : PropertyNumber { public override void CreateChildControls(string renderType, System.Web.UI.Control container) { switch(renderType) { case "edit": DropDownList list = new DropDownList(); list.ID = this.Name; CopyWebAttributes(container, list); list.Items.Add( new ListItem("On", "0") ); list.Items.Add( new ListItem("Off", "1") ); container.Controls.Add(list); container.Controls.Add(CreateParseValidator(list)); break; default: base.CreateChildControls(renderType, container); break; } } } } Buy your collegues an icecream with the money and continue work with EPiServer :D /Øyvind ElektroPost Norway
#14109
Mar 25, 2008 18:44
Vote:
 
:) Thanks a lot! / Ted
#14110
Mar 25, 2008 18:44
Vote:
 
One small addition just after the calls to list.Items.Add(): list.SelectedValue=this.Value.ToString();
#14111
Mar 25, 2008 18:44
Vote:
 
You should do a list.Items.FindByValue(...) to make sure you don't try "select" a value that is not in the list. (In case you change the items in the list after first install.)
#14112
Mar 25, 2008 18:44
* 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.