Ajax Multiple file uploads, multiple files not getting upoaded
<p>I am using Ajax file uploader which can upload multiple files to the database. But I am facing some problems. When I use any master page only 1 file of the multiple selected files get uploaded and all the remaining files don't get uploaded. </p>

<p>But when I don't use any master page, it works just fine.</p>

<p><strong>I am not sure what code to provide here, so please tell me what code I should provide (CS or ASPX) for reference.</strong> </p>

<p>cs code :</p>

<pre><code>protected void UploadComplete(object sender, AjaxControlToolkit.AjaxFileUploadEventArgs e)
    {
        try
        {       

        string path = Server.MapPath("~/Uploads/") + e.FileName;
        string ext = e.FileName.Split('.')[1];
        AjaxFileUpload1.SaveAs(path);
        string content_type="";
        object readOnly = false;

        object missing = System.Reflection.Missing.Value;
        //WdProtectionType typ = WdProtectionType.wdNoProtection;
        Word.Application app = new Word.Application();


            if ((ext == "doc") || (ext == "docx") || (ext == "DOC") || (ext == "DOCX"))
            {
                content_type = "application/vnd.ms-word";


                //Word.Document tempDoc = app.Documents.Open(path);
                //// tempDoc.TrackRevisions = true;
                ////  tempDoc.Protect(typ, ref missing, ref password, ref missing, ref missing);
                //tempDoc.Close(ref Nothing, ref format, ref Nothing);
            }

            if ((ext == "xlsx") || (ext == "xls") || (ext == "XLSX") || (ext == "XLS"))
            {
                content_type = "application/vnd.ms-excel";
                //Excel.Application ex_APP = new Excel.Application();
                //Excel.Workbook book = ex_APP.Workbooks.Open(path);
                //// book.KeepChangeHistory = true;
                //// book.HighlightChangesOnScreen = true;
                //book.Close(Nothing, path, Nothing);
            }

            if ((ext == "pdf") || (ext == "PDF"))
            {
                content_type = "application/pdf";
            }

            if ((ext == "txt") || (ext == "TXT"))
            {
                content_type = "text/plain";
            }


            if ((ext == "jpg") || (ext == "jpeg") || (ext == "JPG") || (ext == "JPEG"))
            {
                content_type = "image/jpeg";
            }


            byte[] imageBytes = File.ReadAllBytes(System.Web.HttpContext.Current.Server.MapPath("~/Uploads/") + e.FileName);
            GENERIC.db.Document_Master_insert(e.FileName.ToString(), 1, imageBytes, "abcd_001", ext, System.DateTime.Now, "0.1", content_type);
            //BindGridviewData();
            File.Delete(Server.MapPath("~/Uploads/") + e.FileName);

        }
        catch (Exception ex)
        {

            throw;
        }


    }
</code></pre>

<p>aspx : </p>

<pre><code>&lt;asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server"&gt;
    &lt;style&gt;
        .modalBackground {
            background-color: Gray;
            filter: alpha(opacity=50);
            opacity: 0.50;
        }

        .pnl {
            background: #333;
            padding: 10px;
            border: 2px solid #ddd;
            float: left;
            font-size: 1.2em;
            color: White;
            position: fixed;
            top: 50%;
            left: 50%;
            z-index: 99999;
            box-shadow: 0px 0px 20px #999; /* CSS3 */
            -moz-box-shadow: 0px 0px 20px #999; /* Firefox */
            -webkit-box-shadow: 0px 0px 20px #999; /* Safari, Chrome */
            border-radius: 3px 3px 3px 3px;
            -moz-border-radius: 3px; /* Firefox */
            -webkit-border-radius: 3px; /* Safari, Chrome */
        }

        .close {
            DISPLAY: block;
            BACKGROUND: url(Images/close.png) no-repeat 0px 0px;
            LEFT: -12px;
            WIDTH: 26px;
            TEXT-INDENT: -1000em;
            POSITION: absolute;
            TOP: -12px;
            HEIGHT: 26px;
        }
    &lt;/style&gt;
    &lt;script type="text/javascript"&gt;
        function Success() {
            document.getElementById("lblMessage").innerHTML = "File Uploaded";

        }

        function Error() {
            document.getElementById("lblMessage").innerHTML = "Upload failed.";
        }
    &lt;/script&gt;
&lt;/asp:Content&gt;
&lt;asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server"&gt;


    &lt;div&gt;
        &lt;asp:GridView ID="gvDetails" CssClass="Gridview" runat="server" AutoGenerateColumns="false" DataKeyNames="CONTENT" OnSelectedIndexChanged="gvDetails_SelectedIndexChanged"&gt;
            &lt;HeaderStyle BackColor="#df5015" /&gt;
            &lt;Columns&gt;

                &lt;asp:TemplateField HeaderText="CODE"&gt;
                    &lt;ItemTemplate&gt;
                        &lt;asp:LinkButton ID="lnkDownload" runat="server" Text='&lt;% #Bind("CODE")%&gt;' CommandName="Select"&gt;&lt;/asp:LinkButton&gt;
                    &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;


                &lt;%--&lt;asp:BoundField DataField="CODE" HeaderText="CODE" /&gt;--%&gt;
                &lt;asp:BoundField DataField="Document_Name" HeaderText="Document_Name" /&gt;
                &lt;%--&lt;asp:TemplateField HeaderText="CONTENT"&gt;
                                &lt;ItemTemplate&gt;
                                    &lt;asp:LinkButton ID="lnkDownload" runat="server" Text="Download" OnClick="lnkDownload_Click"&gt;&lt;/asp:LinkButton&gt;
                                &lt;/ItemTemplate&gt;
                            &lt;/asp:TemplateField&gt;--%&gt;

                &lt;asp:TemplateField HeaderText="PDF"&gt;
                    &lt;ItemTemplate&gt;
                        &lt;asp:LinkButton ID="lnkPdf" runat="server" Text="View_Pdf" OnClick="lnkPdf_Click"&gt;&lt;/asp:LinkButton&gt;
                    &lt;/ItemTemplate&gt;
                &lt;/asp:TemplateField&gt;


            &lt;/Columns&gt;
        &lt;/asp:GridView&gt;
    &lt;/div&gt;
    &lt;div&gt;

        &lt;asp:UpdatePanel ID="UpdatePanel1" runat="server"&gt;
            &lt;ContentTemplate&gt;
                &lt;asp:Button ID="btnUpload" runat="server"
                    Text="Upload File" OnClick="btnUpload_Click" /&gt;
                &amp;nbsp;&amp;nbsp;&amp;nbsp;

                    &lt;%--&lt;asp:Button ID="Open" runat="server"
                        Text="Open File" OnClick="get" /&gt;--%&gt;



                &lt;asp:ModalPopupExtender runat="server"
                    ID="modelPopupExtender1"
                    TargetControlID="btnUpload"
                    PopupControlID="popUpPanel"
                    OkControlID="btOK"
                    BackgroundCssClass="modalBackground"&gt;
                &lt;/asp:ModalPopupExtender&gt;

                &lt;asp:Panel ID="popUpPanel" runat="server" CssClass="pnl"&gt;
                    &lt;div style="font-weight: bold; border: Solid 3px Aqua; background-color: AliceBlue"&gt;

                        &lt;asp:AjaxFileUpload ID="AjaxFileUpload1" runat="server"
                            OnUploadComplete="UploadComplete"
                            OnClientUploadComplete="Success"
                            ThrobberID="loader" Width="400px" /&gt;
                        &lt;asp:Image ID="loader" runat="server"
                            ImageUrl="~/loading.gif"
                            Style="display: None" /&gt;
                    &lt;/div&gt;
                    &lt;br /&gt;
                    &lt;br /&gt;
                    &lt;asp:Label ID="lblMessage" runat="server" /&gt;&lt;br /&gt;
                    &lt;br /&gt;
                    &lt;asp:Button ID="btOK" runat="server" Text="OK" OnClick="btOK_Click" /&gt;
                    &lt;asp:LinkButton ID="LinkButton1" runat="server" CssClass="close"
                        OnClientClick="$find('modelPopupExtender1').hide(); return false;" /&gt;
                &lt;/asp:Panel&gt;
                &lt;/div&gt;
            &lt;/ContentTemplate&gt;
        &lt;/asp:UpdatePanel&gt;
&lt;/asp:Content&gt;
</code></pre>
