<%@ 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>Persisted 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 PersistedFile_FileUploaded(object sender, PersistedFileEventArgs args)
        {
            InsertMsg("File is changed! " + 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>Persisted File Upload</h2>
            <p>The persisted-file control keeps a single current file across postbacks and raises
                <code>FileChanged</code> whenever it is replaced.</p>

            <div class="note">
                This control lost nine members in v5 because v4 declared them on
                <code>UploadFileBase</code> (shared with <code>Uploader</code>) while v5 declared
                them on <code>Uploader</code> alone. v4 code touching
                <code>UploadPersistedFile1.CancelText</code> or <code>.InsertButton</code> would
                not even compile. Restored in 5.3.2 by putting them back on the shared base.
            </div>

            <div class="panel">
                <CuteWebUI:UploadPersistedFile runat="server" ID="PersistedFile1"
                    InsertText="Upload File"
                    CancelText="Cancel"
                    OnFileChanged="PersistedFile_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>
