Exemplo n.º 1
0
        public static HtmlContainerControl Center(
            Control control, bool horizontal, bool vertical, string className = "")
        {
            var outer = new HtmlDiv {
                EnableViewState = false
            };

            //li.Controls.Add(outer);
            if (horizontal)
            {
                outer.AddCssClasses("horz-center");
            }
            if (vertical)
            {
                outer.AddCssClasses("vert-center");
            }
            if (!string.IsNullOrEmpty(className))
            {
                outer.AddCssClasses(className);
            }
            var inner = new HtmlDiv();

            outer.Controls.Add(inner);
            inner.AddCssClasses("center-inner");
            control.AddCssClasses("center-element");

            var index = control.Parent.Controls.IndexOf(control);

            control.Parent.Controls.AddAt(index, outer);
            control.Parent.Controls.Remove(control);
            inner.Controls.Add(control);

            return(outer);
        }
Exemplo n.º 2
0
 public static Control AddTo(this Control control, Control parent,
                             string classes = null, bool clear = false)
 {
     parent.Controls.Add(control);
     if (classes != null)
     {
         control.AddCssClasses(classes, clear);
     }
     return(control);
 }