public HtmlBuilder o_Textarea(string name, Nparams args)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (_formTag == null)
     {
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     }
     _writeCount++;
     if (args != null)
     {
         // scale
         if (args.ContainsKey("cols"))
         {
             string cols = args.Slice <string>("cols");
             if (cols.EndsWith("px", StringComparison.OrdinalIgnoreCase))
             {
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, cols);
             }
             else if (!cols.EndsWith("u", StringComparison.OrdinalIgnoreCase))
             {
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, (int.Parse(cols) * 7).ToString() + "px");
             }
             else
             {
                 _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Cols, cols.Substring(0, cols.Length - 1));
             }
         }
         if (args.ContainsKey("rows"))
         {
             string rows = args.Slice <string>("rows");
             if (rows.EndsWith("px", StringComparison.OrdinalIgnoreCase))
             {
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, rows);
             }
             else if (!rows.EndsWith("u", StringComparison.OrdinalIgnoreCase))
             {
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, (int.Parse(rows) * 7).ToString() + "px");
             }
             else
             {
                 _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Rows, rows.Substring(0, rows.Length - 1));
             }
         }
         if (args.HasValue())
         {
             AddAttribute(args, null);
         }
     }
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Id, name);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, name);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Textarea);
     ElementPush(HtmlTag.Textarea, null);
     return(this);
 }
        public HtmlBuilder x_Input(string name, string value, Nparams args)
        {
            if (name == null)
            {
                throw new ArgumentNullException("name");
            }
            if (value == null)
            {
                throw new ArgumentNullException("value");
            }
            if (_formTag == null)
            {
                throw new InvalidOperationException("Local.UndefinedHtmlForm");
            }
            _writeCount++;
            string type;

            if (args != null)
            {
                type = args.Slice <string>("type", "text");
                // scale
                if (args.ContainsKey("size"))
                {
                    string size = args.Slice <string>("size");
                    if (size.EndsWith("px", StringComparison.OrdinalIgnoreCase))
                    {
                        _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, size);
                    }
                    else if (!size.EndsWith("u", StringComparison.OrdinalIgnoreCase))
                    {
                        _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, (int.Parse(size) * 7).ToString() + "px");
                    }
                    else
                    {
                        _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Size, size.Substring(0, size.Length - 1));
                    }
                }
                if (args.HasValue())
                {
                    AddAttribute(args, null);
                }
            }
            else
            {
                type = "text";
            }
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Id, name);
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, name);
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Type, type);
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Value, value);
            _textWriter.RenderBeginTag(HtmlTextWriterTag.Input);
            _textWriter.RenderEndTag();
            return(this);
        }
 public HtmlBuilder o_Select(string name, Nparams args)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     if (_formTag == null)
     {
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     }
     _writeCount++;
     if (args != null)
     {
         // scale
         if (args.ContainsKey("size"))
         {
             string size = args.Slice <string>("size");
             if (size.EndsWith("px", StringComparison.OrdinalIgnoreCase))
             {
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, size);
             }
             else if (!size.EndsWith("u", StringComparison.OrdinalIgnoreCase))
             {
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, (int.Parse(size) * 7).ToString() + "px");
             }
             else
             {
                 _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Size, size.Substring(0, size.Length - 1));
             }
         }
         if (args.HasValue())
         {
             AddAttribute(args, null);
         }
     }
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Id, name);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, name);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Select);
     ElementPush(HtmlTag.Select, null);
     return(this);
 }
예제 #4
0
 /// <summary>
 /// O_s the textarea.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder o_Textarea(string name, Nparams args)
 {
     if (name == null)
         throw new ArgumentNullException("name");
     if (_formTag == null)
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     _writeCount++;
     if (args != null)
     {
         // scale
         if (args.ContainsKey("cols"))
         {
             var cols = args.Slice<string>("cols");
             if (cols.EndsWith("px", StringComparison.OrdinalIgnoreCase))
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, cols);
             else if (!cols.EndsWith("u", StringComparison.OrdinalIgnoreCase))
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, (int.Parse(cols) * 7).ToString() + "px");
             else
                 _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Cols, cols.Substring(0, cols.Length - 1));
         }
         if (args.ContainsKey("rows"))
         {
             var rows = args.Slice<string>("rows");
             if (rows.EndsWith("px", StringComparison.OrdinalIgnoreCase))
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, rows);
             else if (!rows.EndsWith("u", StringComparison.OrdinalIgnoreCase))
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, (int.Parse(rows) * 7).ToString() + "px");
             else
                 _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Rows, rows.Substring(0, rows.Length - 1));
         }
         if (args.HasValue())
             AddAttribute(args, null);
     }
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Id, name);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, name);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Textarea);
     ElementPush(HtmlTag.Textarea, null);
     return this;
 }
예제 #5
0
        /// <summary>
        /// O_s the select.
        /// </summary>
        /// <param name="name">The name.</param>
        /// <param name="args">The args.</param>
        /// <returns></returns>
        public HtmlBuilder o_Select(string name, Nparams args)
        {
            if (name == null)
                throw new ArgumentNullException("name");
            if (_formTag == null)
                throw new InvalidOperationException("Local.UndefinedHtmlForm");
            _writeCount++;
            if (args != null)
            {
                // scale
                if (args.ContainsKey("size"))
                {
                    var size = args.Slice<string>("size");
                    if (size.EndsWith("px", StringComparison.OrdinalIgnoreCase))
                        _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, size);
                    else if (!size.EndsWith("u", StringComparison.OrdinalIgnoreCase))

                        _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Height, (int.Parse(size) * 7).ToString() + "px");
                    else
                        _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Size, size.Substring(0, size.Length - 1));
                }
                if (args.HasValue())
                    AddAttribute(args, null);
            }
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Id, name);
            _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, name);
            _textWriter.RenderBeginTag(HtmlTextWriterTag.Select);
            ElementPush(HtmlTag.Select, null);
            return this;
        }
예제 #6
0
 /// <summary>
 /// X_s the input.
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="value">The value.</param>
 /// <param name="args">The args.</param>
 /// <returns></returns>
 public HtmlBuilder x_Input(string name, string value, Nparams args)
 {
     if (name == null)
         throw new ArgumentNullException("name");
     if (value == null)
         throw new ArgumentNullException("value");
     if (_formTag == null)
         throw new InvalidOperationException("Local.UndefinedHtmlForm");
     _writeCount++;
     string type;
     if (args != null)
     {
         type = args.Slice<string>("type", "text");
         // scale
         if (args.ContainsKey("size"))
         {
             var size = args.Slice<string>("size");
             if (size.EndsWith("px", StringComparison.OrdinalIgnoreCase))
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, size);
             else if (!size.EndsWith("u", StringComparison.OrdinalIgnoreCase))
                 _textWriter.AddStyleAttributeIfUndefined(HtmlTextWriterStyle.Width, (int.Parse(size) * 7).ToString() + "px");
             else
                 _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Size, size.Substring(0, size.Length - 1));
         }
         if (args.HasValue())
             AddAttribute(args, null);
     }
     else
         type = "text";
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Id, name);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Name, name);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Type, type);
     _textWriter.AddAttributeIfUndefined(HtmlTextWriterAttribute.Value, value);
     _textWriter.RenderBeginTag(HtmlTextWriterTag.Input);
     _textWriter.RenderEndTag();
     return this;
 }
예제 #7
0
        protected internal virtual void AddAttribute(HtmlBuilder b, HtmlTextWriterEx w, HtmlTag tag, Nparams args)
        {
            bool   isSelected;
            string appendStyle;
            bool   isStyleDefined;
            string appendClass;
            bool   isClassDefined;

            if (args != null)
            {
                isSelected     = args.Slice <bool>("selected");
                appendStyle    = args.Slice <string>("appendStyle");
                isStyleDefined = args.ContainsKey("style");
                appendClass    = args.Slice <string>("appendClass");
                isClassDefined = args.ContainsKey("class");
                if (tag == HtmlTag.Tr)
                {
                    IsTrHeader = args.Slice <bool>("header");
                }
                if (args.HasValue())
                {
                    b.AddAttribute(args, null);
                }
            }
            else
            {
                isSelected     = false;
                appendStyle    = string.Empty;
                isStyleDefined = false;
                appendClass    = string.Empty;
                isClassDefined = false;
            }
            // only apply remaining to td/th
            if ((tag == HtmlTag.Td) || (tag == HtmlTag.Th))
            {
                // style
                if (!isStyleDefined)
                {
                    string effectiveStyle;
                    if ((isSelected) && (!string.IsNullOrEmpty(SelectedStyle)))
                    {
                        effectiveStyle = (appendStyle.Length == 0 ? SelectedStyle : SelectedStyle + " " + appendStyle);
                        w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, effectiveStyle);
                    }
                    else if (!string.IsNullOrEmpty(AlternateStyle))
                    {
                        effectiveStyle = (appendStyle.Length == 0 ? AlternateStyle : AlternateStyle + " " + appendStyle);
                        switch (AlternateOrientation)
                        {
                        case TableAlternateOrientation.Column:
                            if ((((ColumnIndex - ColumnOffset - 1 + ColumnPitch) / ColumnPitch) % 2) == 0)
                            {
                                w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, effectiveStyle);
                            }
                            else if (appendStyle.Length > 0)
                            {
                                w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, appendStyle);
                            }
                            break;

                        case TableAlternateOrientation.Row:
                            if ((((RowIndex - RowOffset - 1 + RowPitch) / RowPitch) % 2) == 0)
                            {
                                w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, effectiveStyle);
                            }
                            else if (appendStyle.Length > 0)
                            {
                                w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, appendStyle);
                            }
                            break;

                        default:
                            throw new InvalidOperationException();
                        }
                    }
                    else if (appendStyle.Length > 0)
                    {
                        w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, appendStyle);
                    }
                }
                // class
                if (!isClassDefined)
                {
                    string effectiveClass;
                    if ((isSelected) && (!string.IsNullOrEmpty(SelectedClass)))
                    {
                        effectiveClass = (appendClass.Length == 0 ? SelectedClass : SelectedClass + " " + appendClass);
                        w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, effectiveClass);
                    }
                    else if (!string.IsNullOrEmpty(AlternateClass))
                    {
                        effectiveClass = (appendClass.Length == 0 ? AlternateClass : AlternateClass + " " + appendClass);
                        switch (AlternateOrientation)
                        {
                        case TableAlternateOrientation.Column:
                            if ((((ColumnIndex - ColumnOffset - 1 + ColumnPitch) / ColumnPitch) % 2) == 0)
                            {
                                w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, effectiveClass);
                            }
                            else if (appendClass.Length > 0)
                            {
                                w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, appendClass);
                            }
                            break;

                        case TableAlternateOrientation.Row:
                            if ((((RowIndex - RowOffset - 1 + RowPitch) / RowPitch) % 2) == 0)
                            {
                                w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, effectiveClass);
                            }
                            else if (appendClass.Length > 0)
                            {
                                w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, appendClass);
                            }
                            break;

                        default:
                            throw new InvalidOperationException();
                        }
                    }
                    else if (appendClass.Length > 0)
                    {
                        w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, appendClass);
                    }
                }
            }
        }
예제 #8
0
 /// <summary>
 /// Adds the attribute.
 /// </summary>
 /// <param name="b">The b.</param>
 /// <param name="w">The w.</param>
 /// <param name="tag">The tag.</param>
 /// <param name="args">The args.</param>
 protected internal virtual void AddAttribute(HtmlBuilder b, HtmlTextWriterEx w, HtmlTag tag, Nparams args)
 {
     bool isSelected;
     string appendStyle;
     bool isStyleDefined;
     string appendClass;
     bool isClassDefined;
     if (args != null)
     {
         isSelected = args.Slice<bool>("selected");
         appendStyle = args.Slice<string>("appendStyle");
         isStyleDefined = args.ContainsKey("style");
         appendClass = args.Slice<string>("appendClass");
         isClassDefined = args.ContainsKey("class");
         if (tag == HtmlTag.Tr)
             IsTrHeader = args.Slice<bool>("header");
         if (args.HasValue())
             b.AddAttribute(args, null);
     }
     else
     {
         isSelected = false;
         appendStyle = string.Empty;
         isStyleDefined = false;
         appendClass = string.Empty;
         isClassDefined = false;
     }
     // only apply remaining to td/th
     if (tag == HtmlTag.Td || tag == HtmlTag.Th)
     {
         // style
         if (!isStyleDefined)
         {
             string effectiveStyle;
             if (isSelected && !string.IsNullOrEmpty(SelectedStyle))
             {
                 effectiveStyle = (appendStyle.Length == 0 ? SelectedStyle : SelectedStyle + " " + appendStyle);
                 w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, effectiveStyle);
             }
             else if (!string.IsNullOrEmpty(AlternateStyle))
             {
                 effectiveStyle = (appendStyle.Length == 0 ? AlternateStyle : AlternateStyle + " " + appendStyle);
                 switch (AlternateOrientation)
                 {
                     case TableAlternateOrientation.Column:
                         if ((((ColumnIndex - ColumnOffset - 1 + ColumnPitch) / ColumnPitch) % 2) == 0)
                             w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, effectiveStyle);
                         else if (appendStyle.Length > 0)
                             w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, appendStyle);
                         break;
                     case TableAlternateOrientation.Row:
                         if ((((RowIndex - RowOffset - 1 + RowPitch) / RowPitch) % 2) == 0)
                             w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, effectiveStyle);
                         else if (appendStyle.Length > 0)
                             w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, appendStyle);
                         break;
                     default:
                         throw new InvalidOperationException();
                 }
             }
             else if (appendStyle.Length > 0)
                 w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Style, appendStyle);
         }
         // class
         if (!isClassDefined)
         {
             string effectiveClass;
             if (isSelected && !string.IsNullOrEmpty(SelectedClass))
             {
                 effectiveClass = (appendClass.Length == 0 ? SelectedClass : SelectedClass + " " + appendClass);
                 w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, effectiveClass);
             }
             else if (!string.IsNullOrEmpty(AlternateClass))
             {
                 effectiveClass = (appendClass.Length == 0 ? AlternateClass : AlternateClass + " " + appendClass);
                 switch (AlternateOrientation)
                 {
                     case TableAlternateOrientation.Column:
                         if ((((ColumnIndex - ColumnOffset - 1 + ColumnPitch) / ColumnPitch) % 2) == 0)
                             w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, effectiveClass);
                         else if (appendClass.Length > 0)
                             w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, appendClass);
                         break;
                     case TableAlternateOrientation.Row:
                         if ((((RowIndex - RowOffset - 1 + RowPitch) / RowPitch) % 2) == 0)
                             w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, effectiveClass);
                         else if (appendClass.Length > 0)
                             w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, appendClass);
                         break;
                     default:
                         throw new InvalidOperationException();
                 }
             }
             else if (appendClass.Length > 0)
                 w.AddAttributeIfUndefined(HtmlTextWriterAttribute.Class, appendClass);
         }
     }
 }