Results 1 to 3 of 3

Thread: Keeping the client informed

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    589

    Keeping the client informed

    I have a page where users can add attachments to an email. The code to save the files to the server is below. When I start uploading I will write to the page (for example) 'Uploading File 1 of 4'. When the first file has been saved, I want to refresh the text the user is viewing to say ... 'File 1 uploaded, Uploading File 2 of 4' etc. I don't need to show a progress bar or anything fancy ... but how can you keep the browser updated so the user can see how many files have been uploaded etc.

    Code:
    HttpFileCollection hfc = Request.Files;
    for (int i = 0; i < hfc.Count; i++)
    {
        HttpPostedFile hpf = hfc[i];
        if (hpf.ContentLength > 0)
        {
            hpf.SaveAs(path + ReturnValue.ToString() + "\\" + Path.GetFileName(hpf.FileName));
            //****************** This is where I need to update some text in the browser as each file is uploaded *********************** 
        }
    }

  2. #2
    Learning .Net danasegarane's Avatar
    Join Date
    Aug 2004
    Location
    VBForums
    Posts
    5,853

    Re: Keeping the client informed

    The basic Asp.net upload file control does not support this kind of progress. What you can do either use the Ajax or Jquery for this progress effect.

    Here are the Examples.
    1. Example 1
    2. Example 2
    Please mark you thread resolved using the Thread Tools as shown

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2006
    Posts
    589

    Re: Keeping the client informed

    Quote Originally Posted by danasegarane View Post
    The basic Asp.net upload file control does not support this kind of progress. What you can do either use the Ajax or Jquery for this progress effect.

    Here are the Examples.
    1. Example 1
    2. Example 2
    Hi and thanks for your response.

    In the first example - I don't understand. Where does the interaction between the server and the client take place. The server side code in the .ashx file is just the usual saving of a HttpPostedFile.

    Where/how does the interaction take place between the .ashx code and the jquery code on the client?

    Do you think I could use the same functionality if, instead of saving the files within the .ashx file, I stream them to a web service?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width