<%@ Page Language="c#" %>
<%@ Register Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" TagPrefix="CuteWebUI" %>

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head runat="server">
    <title>Large File Upload - v4 compatibility</title>
    <link rel="stylesheet" href="demo.css" type="text/css" />

    <script runat="server">
        void InsertMsg(string msg)
        {
            ListBoxEvents.Items.Insert(0, msg);
            ListBoxEvents.SelectedIndex = 0;
        }

        void ButtonPostBack_Click(object sender, EventArgs e)
        {
            InsertMsg("You clicked a PostBack Button.");
        }

        void Uploader_FileUploaded(object sender, UploaderEventArgs args)
        {
            InsertMsg("File uploaded! " + args.FileName + ", " + args.FileSize + " bytes.");

            //Copies the uploaded file to a new location.
            //args.CopyTo("c:\\temp\\"+args.FileName);
            //You can also open the uploaded file's data stream.
            //System.IO.Stream data = args.OpenStream();
        }
    </script>
</head>
<body>
    <form id="Form1" method="post" runat="server">
        <div class="content">
            <a class="backlink" href="Default.aspx">&#8592; v4 compatibility demos</a>
            <h2>Large File Upload</h2>
            <p>Large files upload in chunks, so a dropped connection resumes from the last
                completed part instead of restarting.</p>

            <div class="note">
                v4 needed <code>maxRequestLength</code> raised and streamed the whole file in one
                request. On 5.x the same markup uploads in chunks &mdash; set
                <code>Chunked="true"</code> on the modern control, or leave the legacy control
                alone and configure <code>AjaxUploader.ChunkSize</code> in <code>Web.config</code>.
                Resume across sessions is on by <code>AjaxUploader.EnableResume</code>.
            </div>

            <div class="panel">
                <CuteWebUI:Uploader runat="server" ID="Uploader1"
                    InsertText="Upload File"
                    UploadingMsg="Uploading - you can leave this page and resume later"
                    OnFileUploaded="Uploader_FileUploaded" />
            </div>

            <div class="panel">
                <p>Server Trace:</p>
                <asp:ListBox runat="server" ID="ListBoxEvents" />
                <p>
                    <asp:Button ID="ButtonPostBack" Text="This is a PostBack button" runat="server"
                        OnClick="ButtonPostBack_Click" />
                </p>
            </div>
        </div>
    </form>
</body>
</html>
