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 virtual void Render(System.IO.TextWriter writer, UI.UIControlState state, params HtmlAttribute[] attributes)
        {
            writer.Write("<div class=\"");
            if (state.Validated)
            {
                if (string.IsNullOrEmpty(state.ErrorMessage))
                {
                    writer.Write("form-group has-success");
                }
                else
                {
                    writer.Write("form-group has-error");
                }
            }
            else
            {
                writer.Write("form-group");
            }

            writer.WriteLine("\">");

            RenderLabel(writer, state);
            RenderInput(writer, state, attributes);
            RenderHintOrError(writer, state);


            writer.WriteLine("</div>");
        }
Esempio n. 3
0
        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)
 {
     return(new HtmlStandalone("input",
                               new HtmlAttribute("type", "password"),
                               new HtmlAttribute("name", state.Name),
                               new HtmlAttribute("id", state.Name),
                               new HtmlAttribute("value", state.Value)));
 }
 protected override HtmlNode CreateInput(UI.UIControlState state)
 {
     return(new HtmlSimple(
                "input",
                state.Value,
                new HtmlAttribute("type", "text"),
                new HtmlAttribute("class", "colorPicker"),
                new HtmlAttribute("id", state.Name)));
 }
Esempio n. 6
0
 protected override HtmlNode CreateInput(UI.UIControlState state)
 {
     return(new HtmlStandalone("input",
                               new HtmlAttribute("type", "text"),
                               new HtmlAttribute("id", state.Name),
                               new HtmlAttribute("name", state.Name),
                               new HtmlAttribute("value", state.Value),
                               new HtmlAttribute("class", "timepicker")));
 }
 protected override HtmlNode CreateInput(UI.UIControlState state)
 {
     return(new HtmlSimple("textarea",
                           state.Value,
                           new HtmlAttribute("id", state.Name),
                           new HtmlAttribute("name", state.Name),
                           new HtmlAttribute("rows", "5"),
                           new HtmlAttribute("cols", "40")));
 }
 protected override HtmlNode CreateInput(UI.UIControlState state)
 {
     return(new HtmlStandalone("input",
                               new HtmlAttribute("type", "text"),
                               new HtmlAttribute("name", state.Name),
                               new HtmlAttribute("id", state.Name),
                               new HtmlAttribute("value", state.Value),
                               new HtmlAttribute("class", "form-control"),
                               new HtmlAttribute("placeholder", state.Control.GetGlobalizationTerm("placeholder"))));
 }
        protected void RenderInput(System.IO.TextWriter writer, UI.UIControlState state, params HtmlAttribute[] attributes)
        {
            _Input = CreateInput(state);

            for (int i = 0; i < attributes.Length; i++)
            {
                _Input.Attributes[attributes[i].Name] = attributes[i].Value;
            }

            _Input.Write(writer);
        }
        protected override HtmlNode CreateInput(UI.UIControlState state)
        {
            DateTime value = Convert.ToDateTime(state.Value);

            return(new HtmlStandalone("input",
                                      new HtmlAttribute("type", "text"),
                                      new HtmlAttribute("name", state.Name),
                                      new HtmlAttribute("id", state.Name),
                                      new HtmlAttribute("value", value != DateTime.MinValue ? string.Format(state.FormatProvider, "{0:d}", state.Value) : ""),
                                      new HtmlAttribute("class", "datepicker")));
        }
        protected void RenderHintOrError(System.IO.TextWriter writer, UI.UIControlState state)
        {
            if (!string.IsNullOrEmpty(state.ErrorMessage))
            {
                _Hint = new HtmlSimple("span", state.ErrorMessage, new HtmlAttribute("class", "help-block"));
            }
            else
            {
                string hintText = string.IsNullOrEmpty(state.Hint) ? " " : state.Hint;
                _Hint = new HtmlSimple("span", hintText, new HtmlAttribute("class", "help-block"));
            }

            _Hint.Write(writer);
        }
        protected void RenderLabel(System.IO.TextWriter writer, UI.UIControlState state)
        {
            if (_Label == null)
            {
                _Label = new HtmlSimple(
                    "label",
                    state.Label,
                    new HtmlAttribute("for", state.Name),
                    new HtmlAttribute("class", "control-label")
                    );
            }

            _Label.Write(writer);
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        public override void Render(System.IO.TextWriter writer, UI.UIControlState state, params HtmlAttribute[] attributes)
        {
            writer.Write("<div class=\"");
            writer.Write(string.IsNullOrEmpty(state.ErrorMessage) ? "control-group" : "control-group error");
            writer.WriteLine("\">");

            writer.WriteLine("<div class=\"controls\">");
            writer.Write("<label class=\"checkbox\">");
            writer.Write(HtmlHelper.HtmlFormat(state.Label));
            RenderInput(writer, state, attributes);
            writer.WriteLine("</label>");
            RenderHintOrError(writer, state);
            writer.WriteLine("</div>");


            writer.WriteLine("</div>");
        }
Esempio n. 15
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 void RenderInput(System.IO.TextWriter writer, UI.UIControlState state, params HtmlAttribute[] attributes)
        {
            _Input = CreateInput(state);

            for (int i = 0; i < attributes.Length; i++)
            {
                if (attributes[i].Value != null)
                {
                    object itemAtt = (object)_Input.Attributes[attributes[i].Name];
                    if (itemAtt != null)
                    {
                        _Input.Attributes[attributes[i].Name] = itemAtt + " " + attributes[i].Value;
                    }
                    else
                    {
                        _Input.Attributes[attributes[i].Name] = attributes[i].Value;
                    }
                }
            }

            _Input.Write(writer);
        }
Esempio n. 17
0
        public virtual void Render(System.IO.TextWriter writer, UI.UIControlState state, params HtmlAttribute[] attributes)
        {
            if (_Label == null)
            {
                _Label = new HtmlSimple("label", state.Label, new HtmlAttribute("for", state.Name));
            }

            _Label.Write(writer);

            if (_Input == null)
            {
                _Input = CreateInput(state);
            }

            for (int i = 0; i < attributes.Length; i++)
            {
                _Input.Attributes[attributes[i].Name] = attributes[i].Value;
            }

            this._Input.Write(writer);

            if (!string.IsNullOrEmpty(state.ErrorMessage))
            {
                new HtmlSimple("span", state.ErrorMessage, new HtmlAttribute("class", "error")).Write(writer);
            }
            else
            {
                if (!string.IsNullOrEmpty(state.Hint))
                {
                    if (_Hint == null)
                    {
                        _Hint = new HtmlSimple("span", state.Hint, new HtmlAttribute("class", "hint"));
                    }

                    _Hint.Write(writer);
                }
            }
        }
 public override void Render(System.IO.TextWriter writer, UI.UIControlState state, params HtmlAttribute[] attributes)
 {
     RenderInput(writer, state, attributes);
 }
 protected abstract HtmlNode CreateInput(UI.UIControlState state);
Esempio n. 20
0
 public override void Render(System.IO.TextWriter writer, UI.UIControlState state, params HtmlAttribute[] attributes)
 {
     CreateInput(state).Write(writer);
 }