protected override HtmlNode CreateInput(UI.UIControlState state) { HtmlComposite ul = new HtmlComposite("ul", new HtmlAttribute("class", "unstyled")); foreach (KeyValuePair<object, object> item in state.Options) { HtmlComposite li = new HtmlComposite("li"); ul.Children.AddLast(li); string id = state.Name + "_" + item.Key; HtmlComposite label = new HtmlComposite("label", new HtmlAttribute("class", "checkbox")); li.Children.AddLast(label); HtmlStandalone checkbox = new HtmlStandalone("input", new HtmlAttribute("type", "radio"), new HtmlAttribute("id", id), new HtmlAttribute("name", state.Name), new HtmlAttribute("value", item.Key)); if (state.Value.Equals(item.Key)) checkbox.Attributes.AddLast("checked", "checked"); label.Children.AddLast(checkbox); label.Children.AddLast(new HtmlText(" " + item.Value)); } return ul; }
protected override HtmlNode CreateInput(UI.UIControlState state) { HtmlComposite ul = new HtmlComposite("ul"); foreach (KeyValuePair <object, object> item in state.Options) { HtmlComposite li = new HtmlComposite("li"); ul.Children.AddLast(li); string id = state.Name + "_" + item.Key; li.Children.AddLast(new HtmlSimple("label", item.Value, new HtmlAttribute("for", id))); HtmlStandalone checkbox = new HtmlStandalone("input", new HtmlAttribute("type", "checkbox"), new HtmlAttribute("id", id), new HtmlAttribute("name", state.Name), new HtmlAttribute("value", item.Key)); if (state.Value == item.Key) { checkbox.Attributes.AddLast("checked", "checked"); } li.Children.AddLast(checkbox); } return(ul); }
protected override HtmlNode CreateInput(UI.UIControlState state) { HtmlComposite ul = new HtmlComposite("ul"); System.Collections.IEnumerable items = state.Value is string ? ((string)state.Value).Split(',') : (System.Collections.IEnumerable)state.Value; foreach (KeyValuePair<object, object> item in state.Options) { HtmlComposite li = new HtmlComposite("li"); ul.Children.AddLast(li); string id = state.Name + "_" + item.Key; li.Children.AddLast(new HtmlSimple("label", item.Value, new HtmlAttribute("for", id))); HtmlStandalone checkbox = new HtmlStandalone("input", new HtmlAttribute("type", "checkbox"), new HtmlAttribute("id", id), new HtmlAttribute("name", state.Name), new HtmlAttribute("value", item.Key)); if (IsChecked(items, item.Key)) checkbox.Attributes.AddLast("checked", "checked"); li.Children.AddLast(checkbox); } return ul; }
protected override HtmlNode CreateInput(UI.UIControlState state) { HtmlStandalone checkbox = new HtmlStandalone("input", new HtmlAttribute("type", "checkbox"), new HtmlAttribute("id", state.Name), new HtmlAttribute("name", state.Name), new HtmlAttribute("value", "True")); if (Convert.ToBoolean(state.Value)) { checkbox.Attributes.AddLast("checked", "checked"); } return checkbox; }
protected override HtmlNode CreateInput(UI.UIControlState state) { HtmlStandalone checkbox = new HtmlStandalone("input", new HtmlAttribute("type", "checkbox"), new HtmlAttribute("id", state.Name), new HtmlAttribute("name", state.Name), new HtmlAttribute("value", "True")); if (Convert.ToBoolean(state.Value)) { checkbox.Attributes.AddLast("checked", "checked"); } return(checkbox); }