Ejemplo n.º 1
0
        public static MvcHtmlString FieldSetFor(this HtmlHelper helper, Type type, object defaults = null, string legendText = null, object wrapperAttrs = null)
        {
            InputFormBuilder builder = new InputFormBuilder();
            TagBuilder       tag     = builder.FieldsetFor(type, defaults, legendText);

            tag.AttrsIf(wrapperAttrs != null, wrapperAttrs);
            return(tag.ToMvcHtml());
        }
Ejemplo n.º 2
0
        public static MvcHtmlString FieldsetFor(this HtmlHelper helper, dynamic obj, string legendText = null, object wrapperAttrs = null, bool setValues = false)
        {
            InputFormBuilder builder = new InputFormBuilder();
            TagBuilder       tag     = builder.FieldsetForDynamic(obj, legendText, setValues);

            tag.AttrsIf(wrapperAttrs != null, wrapperAttrs);
            return(tag.ToMvcHtml());
        }
Ejemplo n.º 3
0
        public static MvcHtmlString InputsFor(this HtmlHelper helper, Type type, object defaults = null, object wrapperAttrs = null)
        {
            InputFormBuilder builder = new InputFormBuilder();
            TagBuilder       tag     = new TagBuilder("span");

            builder.AppendInputsFor(type, defaults, tag);
            tag.AttrsIf(wrapperAttrs != null, wrapperAttrs);
            return(tag.ToMvcHtml());
        }
Ejemplo n.º 4
0
        private static TagBuilder GetParamsBuilder(Type type, string methodName, string wrapperTagName, Dictionary <string, object> defaults, object htmlAttributes, out int paramCount)
        {
            InputFormBuilder builder = new InputFormBuilder(type);

            builder.AddLabels = true;
            TagBuilder form = builder.MethodForm(wrapperTagName, methodName, defaults, out paramCount)
                              .AttrsIf(htmlAttributes != null, htmlAttributes);

            return(form);
        }
Ejemplo n.º 5
0
        private static InputFormBuilder CreateBuilder(Type type, string labelClass)
        {
            InputFormBuilder builder = new InputFormBuilder();

            if (!string.IsNullOrWhiteSpace(labelClass))
            {
                builder.LabelCssClass = labelClass;
            }
            return(builder);
        }
Ejemplo n.º 6
0
        public static MvcHtmlString InputFor(this HtmlHelper helper,
                                             Type type,
                                             object buttonAttributes  = null,
                                             object wrapperAttributes = null,
                                             object defaultValues     = null,
                                             string name       = null,
                                             string labelClass = null)
        {
            InputFormBuilder builder = CreateBuilder(type, labelClass);

            return(builder.FieldsetFor(type, defaultValues, name)
                   .AttrsIf(wrapperAttributes != null, wrapperAttributes)
                   .ChildIf(buttonAttributes != null, new TagBuilder("span").Button(buttonAttributes))
                   .ToHtml());
        }
Ejemplo n.º 7
0
        public override void ExecuteResult(ControllerContext context)
        {
            StringBuilder output = new StringBuilder();

            if (string.IsNullOrEmpty(ClassName))
            {
                Tag message = new Tag("div", new { Class = "error" }).Text("ClassName not specified");
                output = new StringBuilder(message.ToHtmlString());
            }
            else
            {
                Incubator incubator = ServiceProxySystem.Incubator;
                Type      type;
                incubator.Get(ClassName, out type);
                if (type == null)
                {
                    Tag message = new Tag("div", new { Class = "error" }).Text("The specified className ({0}) was not registered in the ServiceProxySystem"._Format(ClassName));
                    output = new StringBuilder(message.ToHtmlString());
                }
                else
                {
                    InputFormBuilder formBuilder = new InputFormBuilder(type);
                    formBuilder.Layout = Layout;
                    Dictionary <string, object> defaults = new Dictionary <string, object>();
                    if (Defaults != null)
                    {
                        defaults = Defaults.PropertiesToDictionary();
                    }

                    TagBuilder tag = formBuilder.MethodForm(MethodName, defaults);
                    output = new StringBuilder(tag.ToMvcHtml().ToString());
                }
            }

            HttpResponseBase response = context.HttpContext.Response;

            response.Write(output.ToString());
        }
Ejemplo n.º 8
0
        public static TagBuilder InputFor(this HtmlHelper helper, Type type, object defaultValues = null, string name = null, string labelClass = null)
        {
            InputFormBuilder builder = CreateBuilder(type, labelClass);

            return(builder.FieldsetFor(type, defaultValues, name));
        }