Upload Grid Displaying Uploaded File Disappears when Server Trace appears

  •  10-10-2013, 6:20 PM

    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>
View Complete Thread