Exemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="System.Web.UI.Control.PreRender"/> event.
        /// </summary>
        /// <param name="e">An <see cref="System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            HtmlForm form = this.Page.Form;

            if ((form != null) && (form.Enctype.Length == 0))
            {
                form.Enctype = "multipart/form-data";
            }

            List <HttpPostedFile> postedFiles = null;

            if (this.Page.IsPostBack)
            {
                postedFiles = new List <HttpPostedFile>();
            }

            Division fileContainer;
            string   customUniqueID;

            for (int i = 0; i < this.FileCount; i++)
            {
                customUniqueID = this.ClientID + i.ToString();
                if (this.Page.Request.Files[customUniqueID] == null)
                {
                    customUniqueID = null;
                }

                fileContainer = new Division();
                this.Controls.Add(fileContainer);
                fileContainer.CssClass = this.FileCssClass;

                FileUploadEx file = new FileUploadEx(customUniqueID, InputCssClass);
                fileContainer.Controls.Add(file);

                if (file.PostedFile != null && file.PostedFile.FileName.Length > 0)
                {
                    postedFiles.Add(file.PostedFile);
                }
            }

            if (this.Page.IsPostBack)
            {
                this.OnFilesPosted(new FilesPostedEventArgs(postedFiles.ToArray()));
            }

            this.RegisterClientScript();
        }
Exemplo n.º 2
0
        /// <summary>
        /// Raises the <see cref="System.Web.UI.Control.PreRender"/> event.
        /// </summary>
        /// <param name="e">An <see cref="System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            HtmlForm form = this.Page.Form;
            if ((form != null) && (form.Enctype.Length == 0))
            {
                form.Enctype = "multipart/form-data";
            }

            List<HttpPostedFile> postedFiles = null;
            if (this.Page.IsPostBack)
                postedFiles = new List<HttpPostedFile>();

            Division fileContainer;
            string customUniqueID;
            for (int i = 0; i < this.FileCount; i++)
            {
                customUniqueID = this.ClientID + i.ToString();
                if (this.Page.Request.Files[customUniqueID] == null)
                    customUniqueID = null;

                fileContainer = new Division();
                this.Controls.Add(fileContainer);
                fileContainer.CssClass = this.FileCssClass;

                FileUploadEx file = new FileUploadEx(customUniqueID, InputCssClass);
                fileContainer.Controls.Add(file);

                if (file.PostedFile != null && file.PostedFile.FileName.Length > 0)
                    postedFiles.Add(file.PostedFile);
            }

            if (this.Page.IsPostBack)
                this.OnFilesPosted(new FilesPostedEventArgs(postedFiles.ToArray()));

            this.RegisterClientScript();
        }