fileupload doing partial postback on each file upload.

Last post 08-24-2011, 12:27 AM by ibhadelia. 2 replies.
Sort Posts: Previous Next
  •  08-23-2011, 8:02 AM 69770

    fileupload doing partial postback on each file upload.

    fileupload doing partial postback on each file upload.
     
    If i upload 10 files then it will do partial postback 11 times.(10 time for file + 1 time for upload button.)
     
    Let me know how can i avoid extra partial postback.
  •  08-23-2011, 8:27 AM 69771 in reply to 69770

    Re: fileupload doing partial postback on each file upload.

    Hi ibhadelia,
     
    It just do one post back, please try the example below.
     
    When you click on the post back button, the page will do a post back and label1 will add "-1".(click a few times to test it)
     
    Then try upload multiple files, you can see the label1 just add one "-1" in it.
     
    <%@ Page Language="C#" %>

    <%@ Register Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" TagPrefix="CuteWebUI" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1" runat="server">
        <title>example</title>
    </head>

    <script runat="server">
        protected override void OnLoad(EventArgs e)
        {
            if (IsPostBack)
            {
                label1.Text += "1-";
            }
            base.OnLoad(e);
        }
    </script>

    <body>
        <form id="form1" runat="server">
            <asp:Label ID="label1" runat="server"></asp:Label>
            <CuteWebUI:UploadAttachments ID="uploader1" runat="server">
            </CuteWebUI:UploadAttachments>
            <asp:Button ID="button1" runat="server" Text="postback" />
        </form>
    </body>
    </html>
     
    Regards,
     
    Ken
  •  08-24-2011, 12:27 AM 69782 in reply to 69771

    Re: fileupload doing partial postback on each file upload.

    Hello Ken,
     
    Thanks for you quick response, but if you put breakpoint at page load event in your sample, you see its will get hit for each upload. its not rendering that page back, so label's text is not updated; each time fresh request is getting postback so on server you find value of label is always blank.
     
    Imran
View as RSS news feed in XML