AjaxUploader
Search Results for

    Legacy UploadPersistedFile

    UploadPersistedFile is the compatibility control for pages that keep one uploaded file attached to a record.

    Typical examples are:

    • profile photos
    • a single signed document
    • one attachment per database row

    Typical markup

    <%@ Register Assembly="AjaxUploader" Namespace="CuteWebUI" TagPrefix="CuteWebUI" %>
    
    <CuteWebUI:UploadPersistedFile ID="ProfilePhotoUpload" runat="server"
        InsertText="Select file"
        OnFileChanged="ProfilePhotoUpload_FileChanged">
        <ValidateOption AllowedFileExtensions="jpg,png" MaxSizeKB="4096" />
    </CuteWebUI:UploadPersistedFile>
    

    Typical code-behind

    protected void ProfilePhotoUpload_FileChanged(object sender, CuteWebUI.PersistedFileEventArgs e)
    {
        var targetPath = Server.MapPath("~/App_Data/ProfilePhotos/" + e.File.FileName);
        e.File.CopyTo(targetPath);
    }
    

    Most-used members

    Member Purpose
    File Gets the current persisted file wrapper
    FileChanged Fires when the selected persisted file changes
    ChangeFile(...) Replaces the current file by uploading a new one
    ClearFile() Clears the current persisted file selection

    Behavior to expect

    • The control tracks one current file.
    • The File property is available after the upload has been synchronized back through postback.
    • The persisted file wrapper exposes helper methods such as CopyTo, MoveTo, Delete, and OpenStream.

    Related types

    • PersistedFile
    • PersistedFileEventArgs
    • UploaderProvider
    In this article
    Back to top AjaxUploader 5.0 API Reference