Restore clientside file list

3 posts, 0 answers
  1. Jason Rosensweig
    Jason Rosensweig avatar
    9 posts
    Member since:
    Feb 2010

    Posted 16 Nov 2010 Link to this post

    I have an asyncupload control on a form. When the user submits the form, I validate the other form fields server-side and return a message to the user if one or more fields fails that validation. If all of the fields pass, the postback uploads the file as intended. However, if I fail the validation, the asyncupload control file list is cleared. Is there a way to retain the clientside list so the user doesn't have to re-upload the file if I fail the validation? Here is the code that I used for the upload:

    protected void upAttachment_FileUploaded(object sender, FileUploadedEventArgs e)
    {
        if (MessageSent)
        {
            byte[] buffer = new byte[e.File.ContentLength];
            using (Stream stream = e.File.InputStream)
            {
                stream.Read(buffer, 0, e.File.ContentLength);
     
                using (BinaryWriter bWriter = new BinaryWriter(File.Open(UploadDir + "\\" + e.File.FileName, FileMode.Create)))
                {
                    bWriter.Write(buffer);
                }
            }
        }
    }
  2. Genady Sergeev
    Admin
    Genady Sergeev avatar
    1600 posts

    Posted 22 Nov 2010 Link to this post

    Hello Jason Rosensweig,

    Yes, there is a way to do that. I am attaching a sample project that demonstrates how to preserve files across postbacks. The project uses the latest DLL, if you version is an earlier one, please specify it and I we will prepare another sample.

    Greetings,
    Genady Sergeev
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  3. Maxi
    Maxi avatar
    3 posts
    Member since:
    Mar 2012

    Posted 06 Mar 2012 Link to this post

    Hello, i have the 2011 q3 version, and i want to know if you have an example for the version im using, because the actual example is not working, its throws an error in line var row = upload._appendStyledRow();

    thank you. 
Back to Top