for creating a custom macro parameter of type DropDownList. Few hiccups, but ultimately worked great. I tried creating a custom macro parameter of type CheckBoxList, however, and can't get it to work. I don't think it's in my code, per se, but something about the way it interacts with umbraco. The control shows up as a valid parameter type in the macro, and when I insert the macro into a template, it prompts with the 2 values, but clicking OK to insert the macro into the template does nothing and returns the javascript error:
Error: document.forms[0][controlId] is undefined
My code below
Any assistance appreciated,
Jonathan
using System; using System.Web.UI.WebControls; using umbraco.interfaces; using System.Collections.Generic;
namespace CRD.umbraco { public class PickLeftAndOrRight : CheckBoxList, IMacroGuiRendering { protected override void OnLoad(EventArgs e) { base.OnLoad(e);
public string Value { get { // also tried explicitly getting value a la: // return "left"; // and commenting out the rest
List<string> selectedItems = new List<string>(); foreach (ListItem item in this.Items) { if (item.Selected) selectedItems.Add(item.Value); } return string.Join(",", selectedItems.ToArray()); } set { // also tried explicitly setting value a la: // this.Items[0].Selected = true; // and commenting out the rest
List<string> selectedItems = new List<string>(value.Split(new char[] { ',' }));
foreach (ListItem item in this.Items) { if (selectedItems.Contains(item.Value)) item.Selected = true; } } }
Hi, have you had any luck with this problem, I also use Some dropdowns and they work fine, but then I use a RadioButtonList and it gets an javascript error.
Custom DropDownList works; CheckBoxList doesn't
I followed the great example at:
http://www.richardsoeteman.net/2010/01/04/CreateACustomMacroParameterType.aspx
for creating a custom macro parameter of type DropDownList. Few hiccups, but ultimately worked great. I tried creating a custom macro parameter of type CheckBoxList, however, and can't get it to work. I don't think it's in my code, per se, but something about the way it interacts with umbraco. The control shows up as a valid parameter type in the macro, and when I insert the macro into a template, it prompts with the 2 values, but clicking OK to insert the macro into the template does nothing and returns the javascript error:
Error: document.forms[0][controlId] is undefined
My code below
Any assistance appreciated,
Jonathan
Hi, have you had any luck with this problem, I also use Some dropdowns and they work fine, but then I use a RadioButtonList and it gets an javascript error.
/J
is working on a reply...