Esempio n. 1
0
        protected override HtmlNode CreateInput(UI.UIControlState state)
        {
            HtmlComposite select = new HtmlComposite("select",
                                                     new HtmlAttribute("id", state.Name),
                                                     new HtmlAttribute("name", state.Name),
                                                     new HtmlAttribute("class", "form-control"));

            if (state.Options != null)
            {
                foreach (KeyValuePair <object, object> item in state.Options)
                {
                    HtmlSimple option = new HtmlSimple("option", item.Value);
                    option.Attributes.AddLast(new HtmlAttribute("value", item.Key));

                    if (item.Key.ToString().Equals(state.Value.ToString()))
                    {
                        option.Attributes.AddLast("selected", "selected");
                    }

                    select.Children.AddLast(option);
                }
            }

            return(select);
        }
        public static void AppendHtmlOption(this HtmlComposite composite, object value, string text, bool selected)
        {
            HtmlSimple option = new HtmlSimple("option", text,
                                               new HtmlAttribute("value", value));

            if (selected)
            {
                option.Attributes.AddLast("selected", "selected");
            }

            composite.Children.AddLast(option);
        }
Esempio n. 3
0
        protected override HtmlNode CreateInput(UI.UIControlState state)
        {
            HtmlComposite select = new HtmlComposite("select",
                new HtmlAttribute("id", state.Name),
                new HtmlAttribute("name", state.Name));

            foreach (KeyValuePair<object, object> item in state.Options)
            {
                HtmlSimple option = new HtmlSimple("option", item.Value);
                option.Attributes.AddLast(new HtmlAttribute("value", item.Key));

                if (item.Key == state.Value)
                    option.Attributes.AddLast("selected", "selected");

                select.Children.AddLast(option);
            }

            return select;
        }
        protected override HtmlNode CreateInput(UI.UIControlState state)
        {
            HtmlComposite select = new HtmlComposite("select",
                                                     new HtmlAttribute("id", state.Name),
                                                     new HtmlAttribute("name", state.Name));

            foreach (KeyValuePair <object, object> item in state.Options)
            {
                HtmlSimple option = new HtmlSimple("option", item.Value);
                option.Attributes.AddLast(new HtmlAttribute("value", item.Key));

                if (item.Key == state.Value)
                {
                    option.Attributes.AddLast("selected", "selected");
                }

                select.Children.AddLast(option);
            }

            return(select);
        }