Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Loop thorough values of a ListBox

Loop thorough values of a ListBox

Scheduled Pinned Locked Moved ASP.NET
sysadminhelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    awedaonline
    wrote on last edited by
    #1

    I have some files listed on a listbox and want to upload them to the server. The values doesn't need to be selected. But I can't even get it working. Below is my source code: Protected Sub uploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uploadButton.Click If (foundFilesList.Items.Count > 0) Then Dim _fileUpload As New FileUpload() For i As Integer = 0 To foundFilesList.Items.Count - 1 _fileUpload.SaveAs("~\InputFiles\" & foundFilesList.Items(i).ToString()) Next messageLabel.Text = "The displayed files has been uploaded." Else messageLabel.Text = "No file path has been specified." End If End Sub Where is the bug in the code above? I appreciate you usual support. Thanks.

    D 1 Reply Last reply
    0
    • A awedaonline

      I have some files listed on a listbox and want to upload them to the server. The values doesn't need to be selected. But I can't even get it working. Below is my source code: Protected Sub uploadButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uploadButton.Click If (foundFilesList.Items.Count > 0) Then Dim _fileUpload As New FileUpload() For i As Integer = 0 To foundFilesList.Items.Count - 1 _fileUpload.SaveAs("~\InputFiles\" & foundFilesList.Items(i).ToString()) Next messageLabel.Text = "The displayed files has been uploaded." Else messageLabel.Text = "No file path has been specified." End If End Sub Where is the bug in the code above? I appreciate you usual support. Thanks.

      D Offline
      D Offline
      Dinesh Mani
      wrote on last edited by
      #2

      The path "~\InputFiles\" & foundFilesList.Items(i).ToString()) would refer to the "_application root_\InputFiles" on the server. Why would you want to upload from the server to the server?? HTH!

      A 1 Reply Last reply
      0
      • D Dinesh Mani

        The path "~\InputFiles\" & foundFilesList.Items(i).ToString()) would refer to the "_application root_\InputFiles" on the server. Why would you want to upload from the server to the server?? HTH!

        A Offline
        A Offline
        awedaonline
        wrote on last edited by
        #3

        Thanks Mani, The path "~\InputFiles\" & foundFilesList.Items(i).ToString() is my server/application path where I want to save the files displayed on the listbox (foundFilesList ). Since the file names have been on the foundFilesList(listbox). Do you understand what I am trying to do?

        D 1 Reply Last reply
        0
        • A awedaonline

          Thanks Mani, The path "~\InputFiles\" & foundFilesList.Items(i).ToString() is my server/application path where I want to save the files displayed on the listbox (foundFilesList ). Since the file names have been on the foundFilesList(listbox). Do you understand what I am trying to do?

          D Offline
          D Offline
          Dinesh Mani
          wrote on last edited by
          #4

          I'm afraid you cannot do it this way. The source file name is a readonly property on the file upload control and can be set only from the client. You cannot set it in server code and try and start the upload from the server. Only the client browser has to initialize the upload.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups