File Upload cause complete page post back... Basicly the ajax part of the uploader is not working?

Last post 11-26-2012, 5:10 AM by themoonraker. 5 replies.
Sort Posts: Previous Next
  •  10-17-2011, 4:07 PM 70430

    File Upload cause complete page post back... Basicly the ajax part of the uploader is not working?

    I am currently developing a page with ajax Uploader and it is working pretty good. However, i just ran into a problem...  After the file is upload completes and protected void Uploader1_UploadCompleted(object sender, UploaderEventArgs[] args) is executed. The page does a complete refresh which is a problem for me..
     
    I placed the CuteWebUI into a user control ascx i then use the ascx in an aspx page.
     
    Ascx Page

    <div style="margin:0px;">

     

    <CuteWebUI:Uploader ID="FileUploader1" ClientIDMode="Static" runat="server" InsertButtonID='Uploader1Insert' ProgressCtrlID='Uploader1Progress' CancelButtonID='Uploader1Cancel' TempDirectory="~/UploaderTemp" ProgressPanelWidth="300" InsertText="Select Image" onuploadcompleted="Uploader1_UploadCompleted" onfileuploaded="Uploader1_FileUploaded" >

    <ValidateOption AllowedFileExtensions=".png,.jpg,.bmp,.jpeg,.gif, ," />

    <ValidateOption MaxSizeKB="1164" />

    </CuteWebUI:Uploader>

    <asp:Image runat="server" ID="Uploader1Insert" AlternateText="Upload File" ImageUrl="../Images/upload.png" Style="float:left; margin:0px;" />

    <asp:Panel runat="server" ID="Uploader1Progress" BorderColor="Orange" BorderStyle="dashed" BorderWidth="2" Style="float:left; margin:0px; padding:0px; ">

    <asp:Label ID="Uploader1ProgressText" runat="server" ForeColor="Firebrick"></asp:Label>

    </asp:Panel>

    <asp:Image runat="server" ID="Uploader1Cancel" AlternateText="Upload File" ImageUrl="../Images/cancel.png" />

     

    </div>
     
     
    Aspx Page

     

    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">

    <script src="../Scripts/jquery-1.6.4.min.js" type="text/javascript"></script>

     

    <script type="text/javascript">

    $(document).ready(function () {

    alert("page refreshed");

    });

    </script>

     

     

    <uc1:Uploader ID="Uploader1" runat="server" />

    </asp:Content>

  •  10-18-2011, 8:40 AM 70448 in reply to 70430

    Re: File Upload cause complete page post back... Basicly the ajax part of the uploader is not working?

    Hi ScottDolan,
     
    The uplaoder needs to upload the file to the server, so the postback is necessary.
     
     If you want to submit the form at the end, please use the start upload manually example. Demo http://www.ajaxuploader.com/Demo/Start-uploading-manually.aspx
     
    Or use Ajax UpdatePanel with it.
     
    Regards,
     
    Ken
  •  10-18-2011, 8:49 AM 70451 in reply to 70430

    Re: File Upload cause complete page post back... Basicly the ajax part of the uploader is not working?

    After a little research into the problem... I notice the following things.
     
    After selecting the file to upload..   CuteWebUi:Uploader  calls a partial page request and on page load is called.
     
    However, after the progress bar reaches 100% and the file name shows a green check next to it.. It's seems the CuteWebUI:uploader onfileuploaded and onuploadedcompleted events are generated.  After  these events are execute is where the complete page post back occurrs.
     
    Any Help would be great.. 
     
  •  06-15-2012, 12:05 AM 73892 in reply to 70448

    Re: File Upload cause complete page post back... Basicly the ajax part of the uploader is not working?

    I am having the same issue as Scott. Even when the uploader is inside and update panel the entire page is being posted back. I am using the control in a similar way elsewhere and this is not occuring.
    Any ideas on what might be causing the page to do a full postback even when it is inside an update panel? 
  •  06-18-2012, 4:15 AM 73924 in reply to 73892

    Re: File Upload cause complete page post back... Basicly the ajax part of the uploader is not working?

    Hi davior14,
     
    Please try the example below, does it work for you?
     
    When you click on the post back button, the page will do a post back, and the label text will be changed to "post back!". But when I upload a file, the text has not changed, it means that the page has not do the post back.
     
    If it only happens on your page, please create an simple example which can reproduce this issue and post here. I will check it and get back to you as soon as possible. 
    1. <%@ Page Language="C#" %>  
    2.   
    3. <%@ Register Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" TagPrefix="CuteWebUI" %>  
    4. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">  
    5.   
    6. <script runat="server">  
    7.   
    8.     protected void Page_Load(object sender, EventArgs e)  
    9.     {  
    10.   
    11.         if (!IsPostBack)  
    12.         {  
    13.             label1.Text = "first load!";  
    14.         }  
    15.         else  
    16.         {  
    17.             label1.Text = "post back!";  
    18.         }  
    19.     }  
    20. </script>  
    21.   
    22. <html xmlns="http://www.w3.org/1999/xhtml">  
    23. <head runat="server">  
    24.     <title>Untitled Page</title>  
    25. </head>  
    26. <body>  
    27.     <form id="form1" runat="server">  
    28.         <div>  
    29.             <asp:Button ID="btnPostBack" runat="server" Text="Post back" />  
    30.             <asp:Label ID="label1" runat="server"></asp:Label>  
    31.             <asp:ScriptManager ID="ScriptManager1" runat="server">  
    32.             </asp:ScriptManager>  
    33.             <asp:UpdatePanel ID="UpdatePanel1" runat="server">  
    34.                 <ContentTemplate>  
    35.                     <CuteWebUI:UploadAttachments ID="uploader1" runat="server">  
    36.                     </CuteWebUI:UploadAttachments>  
    37.                 </ContentTemplate>  
    38.             </asp:UpdatePanel>  
    39.         </div>  
    40.     </form>  
    41. </body>  
    42. </html>  
    Regards,
     
    Ken 
  •  11-26-2012, 5:10 AM 75347 in reply to 73924

    Re: File Upload cause complete page post back... Basicly the ajax part of the uploader is not working?

    Did anybody ever resolve this? From what I can see, it's actually a Mircrosoft/Ajax issue. When using ClientIDMode="Static" on a master page, Ajax is ignored and a full postback occurs, it happens for lots of different controls. My solution was just to use ClientIDMode="AutoID" on the control itself.
View as RSS news feed in XML