예제 #1
0
        public string RenderLabel(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter   = new HtmlTextWriter(stringWriter);

            var bootStrapBuilderParameters = (BuilderParameters)formBuilderParameters;
            // if there is a Name specified in the DisplayAttribute use it , other wise use the property name
            var displayName = formElement.ControlSpecs.ControlName.SpacePascal();

            if (!String.IsNullOrEmpty(formElement.ControlSpecs.Name))
            {
                displayName = formElement.ControlSpecs.Name;
            }

            // Label
            if (bootStrapBuilderParameters.FormType == BootstrapFormType.Horizontal)
            {
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-3 control-label");
            }
            else
            {
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "control-label");
            }

            textWriter.AddAttribute(HtmlTextWriterAttribute.For, formElement.ControlSpecs.ControlName);
            textWriter.RenderBeginTag(HtmlTextWriterTag.Label);
            textWriter.Write(displayName);
            textWriter.RenderEndTag(); // label
            return(sb.ToString());
        }
예제 #2
0
        public void RenderLabel(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var bootStrapBuilderParameters = (BootStrapBuilderParameters)formBuilderParameters;
            // if there is a Name specified in the DisplayAttribute use it , other wise use the property name 
            var displayName = formElement.ControlSpecs.ControlName.SpacePascal();

            if (!String.IsNullOrEmpty(formElement.ControlSpecs.Name))
            {
                displayName = formElement.ControlSpecs.Name;
            }

            // Label
            if (bootStrapBuilderParameters.FormType == BootstrapFormType.Horizontal)
            {
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-3 control-label");
            }
            else
            {
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "control-label");
            }
            textWriter.AddAttribute(HtmlTextWriterAttribute.For, formElement.ControlSpecs.ControlName);
            textWriter.RenderBeginTag(HtmlTextWriterTag.Label);
            textWriter.Write(displayName);
            textWriter.RenderEndTag(); // label
        }
예제 #3
0
        public string BuildForm(List <FormElement> formElements, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();

            sb.Append(RenderHiddenFields(formElements));

            var groupsofElements = formElements.OrderBy(x => x.ControlSpecs.GroupName).GroupBy(x => x.ControlSpecs.GroupName);
            var useLegend        = (formElements.Select(x => x.ControlSpecs.GroupName).Distinct().Count() > 1);

            foreach (var groupedElements in groupsofElements)
            {
                var groupName = (!String.IsNullOrEmpty(groupedElements.Key)) ? groupedElements.Key : "General";

                sb.Append(this.layoutBuilder.BeginFieldCollection(groupName, useLegend, formBuilderParameters));
                {
                    var elementsToRender = groupedElements.Where(x => x.ControlSpecs.ElementType != ElementType.Hidden)
                                           .OrderBy(x => x.ControlSpecs.Order);

                    // loop over the attributes (ordered)..
                    foreach (var formElement in elementsToRender)
                    {
                        sb.Append(this.RenderElement(formElement, formBuilderParameters));
                    }
                }
                sb.Append(this.layoutBuilder.EndFieldCollection(formBuilderParameters));
            }

            return(sb.ToString());
        }
예제 #4
0
        public string BuildForm(List<FormElement> formElements, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            sb.Append(RenderHiddenFields(formElements));
               
            var groupsofElements = formElements.OrderBy(x => x.ControlSpecs.GroupName).GroupBy(x => x.ControlSpecs.GroupName);
            var useLegend = (formElements.Select(x => x.ControlSpecs.GroupName).Distinct().Count() > 1);

            foreach (var groupedElements in groupsofElements)
            {
                var groupName = (!String.IsNullOrEmpty(groupedElements.Key)) ? groupedElements.Key : "General";

                sb.Append(this.layoutBuilder.BeginFieldCollection(groupName, useLegend, formBuilderParameters));
                {
                    var elementsToRender = groupedElements.Where(x => x.ControlSpecs.ElementType != ElementType.Hidden)
                                                          .OrderBy(x => x.ControlSpecs.Order);

                    // loop over the attributes (ordered)..
                    foreach (var formElement in elementsToRender)
                    {
                       sb.Append(this.RenderElement(formElement, formBuilderParameters));
                    }
                }
                sb.Append(this.layoutBuilder.EndFieldCollection(formBuilderParameters));
               
            }

            return sb.ToString();
        }
예제 #5
0
        public string EndElementContainer(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter   = new HtmlTextWriter(stringWriter);

            ElementContainer.End(textWriter);
            return(sb.ToString());
        }
예제 #6
0
        public string EndElementContainer(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter = new HtmlTextWriter(stringWriter);

            ElementContainer.End(textWriter);
            return sb.ToString();
        }
예제 #7
0
        public string BeginFieldCollection(string groupName, bool useLegend, IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter   = new HtmlTextWriter(stringWriter);

            FieldCollection.Begin(textWriter, groupName, useLegend);

            return(sb.ToString());
        }
예제 #8
0
        public string EndFieldCollection(IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter   = new HtmlTextWriter(stringWriter);

            FieldCollection.End(textWriter);

            return(sb.ToString());
        }
예제 #9
0
        public string EndFieldCollection(IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter = new HtmlTextWriter(stringWriter);

            FieldCollection.End(textWriter);

            return sb.ToString();
        }
예제 #10
0
        public string BeginFieldCollection(string groupName, bool useLegend, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter = new HtmlTextWriter(stringWriter);

            FieldCollection.Begin(textWriter, groupName, useLegend);
            
            return sb.ToString();
        }
예제 #11
0
        public void BeginElementContainer(HtmlTextWriter contextWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            this.elementContainerWriter = contextWriter;
            this.elementContainerWriter.AddAttribute(HtmlTextWriterAttribute.Class, "form-group");

            if (formElement != null && formElement.HasErrors)
            {
                elementContainerWriter.AddAttribute(HtmlTextWriterAttribute.Class, Foundation.Web.Configurations.WebConfigurations.HasErrorsCssClass);
            }

            elementContainerWriter.RenderBeginTag(HtmlTextWriterTag.Div); // div (ElementType-Group)
        }
예제 #12
0
        public string BeginControlContainer(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter   = new HtmlTextWriter(stringWriter);

            var bootStrapBuilderParameters = (BuilderParameters)formBuilderParameters;
            var formType = bootStrapBuilderParameters.FormType;

            ControlContainer.Begin(textWriter, formType);

            return(sb.ToString());
        }
예제 #13
0
        public void BeginControlContainer(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var bootStrapBuilderParameters = (BootStrapBuilderParameters) formBuilderParameters;
            var formType = bootStrapBuilderParameters.FormType;
            if (formType == BootstrapFormType.Horizontal)
            {
                // Controls Div
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-9");
            }

            textWriter.RenderBeginTag(HtmlTextWriterTag.Div);
            
        }
예제 #14
0
        public void BeginFieldCollection(string groupName, bool useLegend, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            this.collectionWriter = contextWriter;
            collectionWriter.RenderBeginTag(HtmlTextWriterTag.Fieldset); // start field set

            // if at least one group name is there , then use legend (field container)

            if (useLegend)
            {
                collectionWriter.RenderBeginTag(HtmlTextWriterTag.Legend); // start legend tag
                collectionWriter.Write(groupName);
                collectionWriter.RenderEndTag(); // legend
            }
        }
예제 #15
0
        public void BeginFieldCollection(string groupName, bool useLegend, IFormBuilderParameters formBuilderParameters)
        {
            var sb           = new StringBuilder();
            var stringWriter = new StringWriter(sb);

            this.collectionWriter = contextWriter;
            collectionWriter.RenderBeginTag(HtmlTextWriterTag.Fieldset); // start field set

            // if at least one group name is there , then use legend (field container)

            if (useLegend)
            {
                collectionWriter.RenderBeginTag(HtmlTextWriterTag.Legend); // start legend tag
                collectionWriter.Write(groupName);
                collectionWriter.RenderEndTag();                           // legend
            }
        }
예제 #16
0
        public string RenderElement(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();

            sb.Append(this.layoutBuilder.BeginElementContainer(formElement, formBuilderParameters));
            {
                sb.Append(this.layoutBuilder.RenderLabel(formElement, formBuilderParameters));
                sb.Append(this.layoutBuilder.BeginControlContainer(formElement, formBuilderParameters));
                {
                    var elementBlock = this.elementGenerator.RenderElement(formElement);

                    elementBlock.MergeAttributes(formElement.ValidationAttributes);

                    sb.Append(elementBlock);
                }
                sb.Append(this.layoutBuilder.EndControlContainer(formElement, formBuilderParameters));
            }
            sb.Append(this.layoutBuilder.EndElementContainer(formElement, formBuilderParameters));

            return(sb.ToString());
        }
예제 #17
0
        public string RenderElement(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            
            sb.Append(this.layoutBuilder.BeginElementContainer(formElement, formBuilderParameters));
            {
                sb.Append(this.layoutBuilder.RenderLabel(formElement, formBuilderParameters));
                sb.Append(this.layoutBuilder.BeginControlContainer(formElement, formBuilderParameters));
                {
                    var elementBlock = this.elementGenerator.RenderElement(formElement);

                    elementBlock.MergeAttributes(formElement.ValidationAttributes);
                    elementBlock.MergeAttributes(formElement.AppendedHtmlAttributes);

                    sb.Append(elementBlock);
                }
                sb.Append(this.layoutBuilder.EndControlContainer(formElement, formBuilderParameters));
            }
            sb.Append(this.layoutBuilder.EndElementContainer(formElement, formBuilderParameters));

            return sb.ToString();
        }
예제 #18
0
 public void EndFieldCollection(IFormBuilderParameters formBuilderParameters)
 {
     this.collectionWriter.RenderEndTag(); // div (field set)
 }
예제 #19
0
        public string BeginControlContainer(FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var sb = new StringBuilder();
            var stringWriter = new StringWriter(sb);
            var textWriter = new HtmlTextWriter(stringWriter);
 
            var bootStrapBuilderParameters = (BuilderParameters) formBuilderParameters;
            var formType = bootStrapBuilderParameters.FormType;
            ControlContainer.Begin(textWriter, formType);

            return sb.ToString();
        }
예제 #20
0
 public void EndFieldCollection(IFormBuilderParameters formBuilderParameters)
 {
     this.collectionWriter.RenderEndTag(); // div (field set)
 }
예제 #21
0
        public void BeginElementContainer(HtmlTextWriter contextWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            this.elementContainerWriter = contextWriter;
            this.elementContainerWriter.AddAttribute(HtmlTextWriterAttribute.Class, "form-group");

            if (formElement != null && formElement.HasErrors)
            {
                elementContainerWriter.AddAttribute(HtmlTextWriterAttribute.Class, Foundation.Web.Configurations.WebConfigurations.HasErrorsCssClass);
            }

            elementContainerWriter.RenderBeginTag(HtmlTextWriterTag.Div); // div (ElementType-Group)
        }
예제 #22
0
 public void EndControlContainer(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
 {
     textWriter.RenderEndTag(); // div (ElementType-Group)
 }
예제 #23
0
 public void EndElementContainer(HtmlTextWriter textWriter, IFormBuilderParameters formBuilderParameters)
 {
     this.elementContainerWriter.RenderEndTag(); // div (ElementType-Group)
 }
예제 #24
0
 public void EndElementContainer(HtmlTextWriter textWriter, IFormBuilderParameters formBuilderParameters)
 {
     this.elementContainerWriter.RenderEndTag(); // div (ElementType-Group)
 }
예제 #25
0
        public void BeginControlContainer(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
        {
            var bootStrapBuilderParameters = (BootStrapBuilderParameters)formBuilderParameters;
            var formType = bootStrapBuilderParameters.FormType;

            if (formType == BootstrapFormType.Horizontal)
            {
                // Controls Div
                textWriter.AddAttribute(HtmlTextWriterAttribute.Class, "col-lg-9");
            }

            textWriter.RenderBeginTag(HtmlTextWriterTag.Div);
        }
예제 #26
0
 public void EndControlContainer(HtmlTextWriter textWriter, FormElement formElement, IFormBuilderParameters formBuilderParameters)
 {
     textWriter.RenderEndTag(); // div (ElementType-Group)
 }