Upload Grid Displaying Uploaded File Disappears when Server Trace appears

Last post 10-14-2013, 1:05 PM by Kenneth. 3 replies.
Sort Posts: Previous Next
  •  10-10-2013, 6:20 PM 78099

    Upload Grid Displaying Uploaded File Disappears when Server Trace appears

    I am using the single file upload and note that after the file is upload, the gride with the file name and check mark appear for only a second, then immediately replaced by the Trace information.  I can not figure out what is caused the grid to disappear.  

     

    Also, I would like to customize the grid to remove the "delete" and replace it with a link to open the file that was just uploaded.

    Can you help?

    http://www.screencast.com/t/zmO735sWx

    <%@ Page aspcompat=true  Language="VBScript"%>
    <%@Register Namespace="CuteWebUI" Assembly="CuteWebUI.AjaxUploader" TagPrefix="CuteWebUI"%>
    <%
    dim upload_path,fullpath,pk_indoc,play,pk_proj,indoc_nbr,file,filesize,p_or_a,title_of_file,dataprovider,dataproviderowner,sqlsrc,conn,rs,path_server,msg,random_number


    pk_indoc = request.querystring("pk_indoc")
    play =request.querystring("play")
    pk_proj = request.querystring("pk_proj")
    indoc_nbr = request.querystring("indoc_nbr")
    upload_path = request.querystring("upload_path")
    fullpath = Request.querystring("folder") & "in_a_" & request.querystring("pk_proj") & "_" & request.querystring("indoc_nbr") & "_" & random_number &".pdf"
    title_of_file =  "in_a_" & request("pk_proj") & "_" & indoc_nbr & "_" & DateTime.Now().ToString("yyyyMMddHHmmss")

    dataprovider =  "Provider=SQLOLEDB;Server=localhost;database=xxxxx;UID=david;PWD=xxxx;"
    dataproviderowner = "dbo"


    %>

    <html>
    <head>
    <title>Indoc Upload</title>
    <script runat="server">
     Protected Overrides Sub OnLoad(e As EventArgs)
     h1.Value = Uploader1.ValidateOption.AllowedFileExtensions
     MyBase.OnLoad(e)
    End Sub
    </script>


    <script runat="server">
    Private Sub InsertMsg(msg As String)
            ListBoxEvents.Items.Insert(0, msg)
                          'ListBoxEvents.SelectedIndex = 0
                          End Sub
    </script>
    <script runat="server">
       Private Sub Uploader_FileUploaded(ByVal sender As Object, ByVal args As UploaderEventArgs)
       Dim newdirectory as string = request.QueryString("upload_path")
       Dim title_of_file as string  = "in_a_" & request.QueryString("pk_proj") & "_" & request.QueryString("indoc_nbr") & "_"& DateTime.Now().ToString("yyyyMMddHHmmss") & Path.GetExtension(args.FileName)
       Dim oldfilepath As String = newdirectory & "/old_" & title_of_file
       Dim filepath As String = newdirectory &"/" & title_of_file

           If System.IO.File.Exists(filepath) Then
             args.MoveTo(oldfilepath)
             return
             end if
           InsertMsg("File Uploaded Successfully! Saved As:" & title_of_file & ", " + args.FileSize.ToString() & " bytes.")
           args.MoveTo(filepath)
           UpdateRec()
       End Sub
    </script>
    <script runat="server">
    Dim strConnection As String = "Data Source=SQLOLEDB;Server=localhost\loc1;database=tlsolutionsonline;UID=david;PWD=gordon111;"
    Dim objConnection As SqlConnection

    Private Sub UpdateRec()
     Dim dbfilename as string  = "in_" & request.QueryString("pa") &"_"& request.QueryString("pk_proj") & "_" & request.QueryString("indoc_nbr") & "_"& DateTime.Now().ToString("yyyyMMddHHmmss")
     Dim strSQL As String = "UPDATE locindocuments" & _
                            " SET scan_in_flag = 1, scan_in_name = '"& dbfilename &"'"& _
                            " WHERE locrest ="& request.QueryString("indoc_nbr") &" and  fk_proj =" & request.QueryString("pk_proj")

     Connect()
     Dim dbComm As New SqlCommand(strSQL, objConnection)
     dbComm.ExecuteNonQuery()
     Disconnect()
    End Sub

    Private Sub Connect()
     If objConnection Is Nothing Then
       objConnection = New SqlConnection(strConnection)
     End If

     If objConnection.State = ConnectionState.Closed Then
       objConnection.Open()
     End If
    End Sub

    Private Sub Disconnect()
     objConnection.Close()
    End Sub
    </script>

    <style type="text/css">
       body{
           font-family: verdana;
           font-size: 10px;
       }
       #ListBoxEvents {
       border: none;
       }
    </style>
    </head>
    <body>
      <form id="Form1" method="post" runat="server">
          <asp:HiddenField ID="h1" runat="server" />
              <div>
                  <CuteWebUI:Uploader runat="server" ID="Uploader1" OnFileUploaded="Uploader_FileUploaded">
                  <ValidateOption AllowedFileExtensions="pdf" />
          </CuteWebUI:Uploader>
              </div><br/>
           <p>
             <asp:ListBox runat="server" ID="ListBoxEvents"/>
          </p>
      </form>
    </body>
    </html>
    <script type ="text/javascript">
    var h1=document.getElementById("<%= h1.ClientID %>");
    function CuteWebUI_AjaxUploader_OnSelect(files)
    {
     for(var i=0;i<files.length;i++)
     {
         if(files[i].FileName.substring(files[i].FileName.lastIndexOf(".")+1)!="pdf")
         {
           //h1.value is the AllowedFileExtensions string of uploader
           //files[i].FileName is the current upload file name
           alert("The file "+ files[i].FileName+ " is not supported. Only the following extensions "+ h1.value);
           return false;
         }
     }
    }
    </script>
  •  10-11-2013, 1:25 PM 78107 in reply to 78099

    Re: Upload Grid Displaying Uploaded File Disappears when Server Trace appears

    Hi cjchamber,

     

    What you are using is "CuteWebUI:Uploader", it has not the attachment table. If you want to show the attachment table after upload, please use "CuteWebUI:UploadAttachments".

     

    And you can refer to http://www.ajaxuploader.com/Demo/Ajax-based-File-storage.aspx, it shows you how to create your own custom attachment table.

     

    Regards,

     

    Ken 

  •  10-12-2013, 3:40 PM 78115 in reply to 78107

    Re: Upload Grid Displaying Uploaded File Disappears when Server Trace appears

    Thanks Ken.  I'll look into it.  I was just curious because the grid (single upload / one row) actually flashes for a second then disappears.  (You can see it in the video).  Any reason why?
  •  10-14-2013, 1:05 PM 78124 in reply to 78115

    Re: Upload Grid Displaying Uploaded File Disappears when Server Trace appears

    hi cjchamber,

     

    It is the correct behavior. What you saw is the queue table, it only appears when uploading. So after uploaded, it will disappear. This is why I let you use "CuteWebUI:UploadAttachments".

     

    Regards,

     

    Ken 

View as RSS news feed in XML