About RadUpload

Thread is closed for posting
3 posts, 0 answers
  1. dhara
    dhara avatar
    2 posts
    Member since:
    May 2011

    Posted 18 May 2011 Link to this post

    Hello Everyone,
                            I used Radupload in my webpage.and insert multiple docs in database..but when i refresh this page insert previous data automatically....if anyone has solution give it..

    Thanks..

    My Code is Here...
      <telerik:RadScriptManager id="ScriptManager1" runat="server" />
            
              
                
                <telerik:RadProgressManager id="Radprogressmanager1" runat="server" />
                
                <div style="position: relative;">
                    <table>
                     <tr>
                            <td id="controlContainer">
                                <telerik:RadUpload
                                    ID="RadUpload1"
                                    runat="server"
                                    InitialFileInputsCount="1"
                                    MaxFileInputsCount="5"
                                    AllowedFileExtensions=".jpg,.jpeg"  ControlObjectsVisibility="None" />
                                    
                                <telerik:RadProgressArea id="progressArea1" runat="server"/>
                                <asp:Button id="buttonSubmit" runat="server" CssClass="RadUploadSubmit" OnClick="buttonSubmit_Click" Text="Submit" style="MARGIN-TOP: 6px" />
                            </td>
                            <td>
                                <div class="smallModule">
                                    <div class="rc1"><div class="rc2"><div class="rc3" style="width:240px">
                                        <div class="title" style="color: green">Uploaded valid files (*.jpg, *.jpeg):</div>
                                        
                                        <asp:Label ID="labelNoResults" runat="server" Visible="True">No uploaded files</asp:Label>
                                        
                                        <asp:Repeater ID="repeaterValidResults" runat="server" Visible="False">
                                            <ItemTemplate>
                                                <%#DataBinder.Eval(Container.DataItem, "FileName")%>
                                                (<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>)<br /><br />
                                            </ItemTemplate>
                                        </asp:Repeater>
                                        
                                        
                                        <div class="title" style="color: red; padding-top: 40px;">Invalid files:</div>
                                        
                                        <asp:Label id="labelNoInvalidResults" runat="server" Visible="True">No invalid files</asp:Label>
                                        
                                        <asp:repeater id="repeaterInvalidResults" runat="server" visible="False">
                                            <itemtemplate>
                                                File: <%#DataBinder.Eval(Container.DataItem, "FileName") %>
                                                (<%#DataBinder.Eval(Container.DataItem, "ContentLength").ToString() + " bytes"%>)
                                                <br />
                                                Mime-type: <%#DataBinder.Eval(Container.DataItem, "ContentType").ToString()%>
                                            </itemtemplate>
                                        </asp:repeater>
                                    </div></div></div>
                                </div>
                            </td>
                        </tr>
                     </table>
                </div>


    and .cs file coding

     protected void buttonSubmit_Click(object sender, System.EventArgs e)
        {
            
                BindValidResults();
          
                BindInvalidResults();

                //Remove this line if you do not want to delete the files
                //in the location where they have been saved
                DeleteFiles();
                //RadUpload1.UploadedFiles.Clear();
                //int j = RadUpload1.UploadedFiles.Count;
              
           
        }

        private void BindValidResults()
        {
            if (RadUpload1.UploadedFiles.Count > 0)
            {
                //foreach (UploadedFile validFile in RadUpload1.UploadedFiles)
                //{
                //    string targetFolder = Server.MapPath("~/images/");
                //    validFile.SaveAs(Path.Combine(targetFolder, validFile.GetName()), true);
                //}
                for (int i = 0; i < RadUpload1.UploadedFiles.Count; i++)
                {
                    FileName = RadUpload1.UploadedFiles[i].FileName.ToString();
                    pa = "~/images/" + FileName;
                    string fad = Server.MapPath("images/" + RadUpload1.UploadedFiles[i].FileName.ToString());
                    RadUpload1.UploadedFiles[i].SaveAs(fad);
                    // string va = "~/" + ;

                    string str = "insert into generaldocuments(Doc,date) values('" + pa + "','" + System.DateTime.Today.Date.ToShortDateString() + "')";
                    int j = obj.FireQuery(str);

                }
                labelNoResults.Visible = false;
                repeaterValidResults.Visible = true;
                repeaterValidResults.DataSource = RadUpload1.UploadedFiles;
                repeaterValidResults.DataBind();
            }
            else
            {
                labelNoResults.Visible = true;
                repeaterValidResults.Visible = false;
            }
        }

        private void BindInvalidResults()
        {
            if (RadUpload1.InvalidFiles.Count > 0)
            {
                labelNoInvalidResults.Visible = false;
                repeaterInvalidResults.Visible = true;
                repeaterInvalidResults.DataSource = RadUpload1.InvalidFiles;
                repeaterInvalidResults.DataBind();
            }
            else
            {
                labelNoInvalidResults.Visible = true;
                repeaterInvalidResults.Visible = false;
            }
        }

        /// <summary>
        /// For the purpose of this demo we delete the files collection in the targetfolder
        /// to prevent it from growing infinitely
        /// </summary>
        private void DeleteFiles()
        {
            string targetFolder = Server.MapPath("~/images/");

            DirectoryInfo targetDir = new DirectoryInfo(targetFolder);

            try
            {
                foreach (FileInfo file in targetDir.GetFiles())
                {
                    if ((file.Attributes & FileAttributes.ReadOnly) == 0) file.Delete();
                }
            }
            catch (IOException)
            {
            }
        }
  2. Peter Filipov
    Admin
    Peter Filipov avatar
    1028 posts

    Posted 20 May 2011 Link to this post

    Hello dhara,

    Please consult with the following forum post. Refreshing the page resubmits all the data from the buffer. Here is a sample video how the data is resent.

    Regards,
    Peter Filipov
    the Telerik team

    Browse the vast support resources we have to jump start 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. UI for ASP.NET Ajax is Ready for VS 2017
  4. dhara
    dhara avatar
    2 posts
    Member since:
    May 2011

    Posted 23 May 2011 Link to this post

    Thanks Peter Filipov .
Back to Top