Essential Studio for Asp.Net | Demos

SHOWCASE SAMPLES
Showcase samples
    Select a file to upload
    <%@ Page Title="UploadBox-Default Functionalities-ASP.NET-SYNCFUSION" Language="C#" MasterPageFile="~/Samplebrowser.Master" AutoEventWireup="true" CodeBehind="DefaultFunctionalities.aspx.cs" Inherits="WebSampleBrowser.UploadBox.DefaultFunctionalities" %>
    
    <asp:Content ID="Content3" ContentPlaceHolderID="StyleSection" runat="server">
        <style type="text/css">
            .posupload {
                margin-left: 50px;
                margin-top: 20px;
            }
    
            .cols-sample-area {
                position: relative;
            }
    
            .uploadtext {
                text-align:center;
            }
        </style>
    </asp:Content>
    <asp:Content ID="Content5" ContentPlaceHolderID="ControlsSection" runat="server">
        <div class="frame">
            <div class="control">
                 <div class="uploadtext">Select a file to upload </div>
                <div class="posupload">
                    <ej:UploadBox ID="Upload1" runat="server" SaveUrl="saveFiles.ashx" RemoveUrl="removeFiles.ashx"></ej:UploadBox>
                </div>
            </div>
        </div>
    </asp:Content>
    
    
    using System;
    using System.Data;
    using System.Configuration;
    using System.Collections;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.IO;
    
    namespace WebSampleBrowser.UploadBox
    {
        public partial class DefaultFunctionalities : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
               // var fileName = Path.GetFileName();
            }
            
        }
    }
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Web;
    
    namespace WebSampleBrowser.UploadBox
    {
        /// <summary>
        /// Summary description for saveFiles
        /// </summary>
        public class saveFiles : IHttpHandler
        {
    
            public void ProcessRequest(HttpContext context)
            {
                string targetFolder = HttpContext.Current.Server.MapPath("uploadfiles");
                if (!Directory.Exists(targetFolder))
                {
                    Directory.CreateDirectory(targetFolder);
                }
                HttpRequest request = context.Request;
                HttpFileCollection uploadedFiles = context.Request.Files;
                if (uploadedFiles != null && uploadedFiles.Count > 0)
                {
                    for (int i = 0; i < uploadedFiles.Count; i++)
                    {
                        string fileName = uploadedFiles[i].FileName;
                        int indx = fileName.LastIndexOf("\\");
                        if (indx > -1)
                        {
                            fileName = fileName.Substring(indx + 1);
                        }
                        //uploadedFiles[i].SaveAs(targetFolder + "\\" + fileName);
                    }
                }
                else
                {
    
                }
            }
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }
    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Web;
    
    namespace WebSampleBrowser.UploadBox
    {
        /// <summary>
        /// Summary description for removeFiles
        /// </summary>
        public class removeFiles : IHttpHandler
        {
    
            public void ProcessRequest(HttpContext context)
            {
                System.Collections.Specialized.NameValueCollection s = context.Request.Params;
                string fileName = s["fileNames"];
                string targetFolder = HttpContext.Current.Server.MapPath("uploadfiles");
                if (!Directory.Exists(targetFolder))
                {
                    Directory.CreateDirectory(targetFolder);
                }
    
                string physicalPath = targetFolder + "\\" + fileName;
                if (System.IO.File.Exists(physicalPath))
                {
                    System.IO.File.Delete(physicalPath);
                }
    
            }
    
            public bool IsReusable
            {
                get
                {
                    return false;
                }
            }
        }
    }