<%@ 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>Upload Validation - 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.");
        }
    </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>Upload Validation</h2>
            <p>Restrict what may be selected and uploaded. <code>ValidateOption</code> is enforced
                on the server as well as the client.</p>

            <div class="note">
                <code>DialogFilter</code> was inert before 5.3.2 - it stored to ViewState and was
                never read, so a page restricting uploads to images accepted anything, including
                executables. It now feeds the allowed-extension list, with
                <code>ValidateOption</code> still winning where both are set.
            </div>

            <div class="panel">
                <CuteWebUI:Uploader runat="server" ID="Uploader1" InsertText="Upload"
                    DialogFilter="Images|*.jpg;*.jpeg;*.png;*.gif"
                    FileTypeNotSupportMsg="Sorry - {0} files are not accepted here."
                    FileTooLargeMsg="{0} is too large ({1}). The limit is {2}."
                    OnFileUploaded="Uploader_FileUploaded">
                    <ValidateOption MaxSizeKB="2048" />
                </CuteWebUI:Uploader>
            </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 class="note">
                The two message properties above are also new in 5.3.2. v4 rendered these strings
                itself; in v5 the text came from the engine's locale packs and the properties were
                never read, so a translated site silently reverted to English. v4's positional
                placeholders (<code>{0}</code>, <code>{1}</code>, <code>{2}</code>) are translated
                to the engine's named tokens for you.
            </div>
        </div>
    </form>
</body>
</html>
