Ejemplo n.º 1
0
        /// <summary>
        /// Creates the control main element.
        /// </summary>
        /// <returns>The control IFWHtmlElement interface.</returns>
        protected override IFWHtmlElement CreateControl()
        {
            var element = new FWDivElement();

            element.MergeAttributes(Attributes);
            if (!string.IsNullOrWhiteSpace(CustomCss))
            {
                element.AddCssClass(CustomCss);
            }

            element.Id       = Id;
            element.DataType = "fw-fileupload";

            element.Attributes.Add("data-maxfiles", _maxFiles.ToString());
            element.Attributes.Add("data-maxfilesdsc", ViewResources.Upload_File_Limit);
            element.Attributes.Add("data-maxfilesize", _maxFileSize.ToString());
            element.Attributes.Add("data-maxfilesizedsc", ViewResources.Upload_File_Size_Limit);
            if (_allowedMimes != null)
            {
                element.Attributes.Add("data-allowedmimes", string.Join(",", _allowedMimes));
                element.Attributes.Add("data-allowedmimesdsc", ViewResources.Upload_File_Invalid);
            }

            if (DisplayLabel)
            {
                FWLabelControl label = new FWLabelControl(Name, DisplayName, IsRequired, Tooltip);
                label.AddCssClass("control-label");
                element.Add(label.ToString());
            }

            FWDivElement dropzone = CreateDropzone();

            switch (_layout)
            {
            case FWUploadLayout.Input:
                AddInputLayout(dropzone);
                break;

            case FWUploadLayout.Dropzone:
                AddDropzoneLayout(dropzone);
                break;

            default:
                dropzone.Attributes.Add("data-theme", "custom");
                dropzone.Add(LayoutBody);
                break;
            }

            element.Add(dropzone.ToString());

            return(element);
        }
        /// <summary>
        /// Creates the framework control.
        /// </summary>
        /// <param name="context">Contains information associated with the current HTML tag.</param>
        /// <param name="output">A stateful HTML element used to generate an HTML tag.</param>
        /// <returns>The control instance.</returns>
        protected override IFWHtmlElement RenderControl(TagHelperContext context, TagHelperOutput output)
        {
            FWLabelControl control = new FWLabelControl(For.Metadata.PropertyName, For.Metadata.DisplayName, For.Metadata.IsRequired, null);

            return(control);
        }