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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. FileUpload control issue

FileUpload control issue

Scheduled Pinned Locked Moved ASP.NET
helpquestion
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.
  • K Offline
    K Offline
    kenexcelon
    wrote on last edited by
    #1

    I am running into an issue with the fileupload control. Standard code... just a test After clicking on button1 I do get the Yay response. Clicking button1 again right after, I get the Nay response. However, if I choose a file and then click on button1 and it has a file, I get the Yay response and the text in the upload control clears. I refresh the page, and I get the Yay response. Is there a way to control this?

        protected void Button1\_Click(object sender, EventArgs e)
        {
            if (this.FileUpload1.HasFile)
            {
                Response.Write("Yay!");
    
            }
            else
                Response.Write("Nay!");
        }
    
    T 1 Reply Last reply
    0
    • K kenexcelon

      I am running into an issue with the fileupload control. Standard code... just a test After clicking on button1 I do get the Yay response. Clicking button1 again right after, I get the Nay response. However, if I choose a file and then click on button1 and it has a file, I get the Yay response and the text in the upload control clears. I refresh the page, and I get the Yay response. Is there a way to control this?

          protected void Button1\_Click(object sender, EventArgs e)
          {
              if (this.FileUpload1.HasFile)
              {
                  Response.Write("Yay!");
      
              }
              else
                  Response.Write("Nay!");
          }
      
      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      That is how the file up load works. The file upload control will post the file only once. Think about it. If you have a file selected by the user, would you want that file to be sent to the server on every additional postback? protected void Button1_Click(object sender, EventArgs e) { if (this.FileUpload1.HasFile) { Response.Write("Yay!"); //Implement method to save file } else Response.Write("Nay!"); }

      I didn't get any requirements for the signature

      K 1 Reply Last reply
      0
      • T ToddHileHoffer

        That is how the file up load works. The file upload control will post the file only once. Think about it. If you have a file selected by the user, would you want that file to be sent to the server on every additional postback? protected void Button1_Click(object sender, EventArgs e) { if (this.FileUpload1.HasFile) { Response.Write("Yay!"); //Implement method to save file } else Response.Write("Nay!"); }

        I didn't get any requirements for the signature

        K Offline
        K Offline
        kenexcelon
        wrote on last edited by
        #3

        I understand that's how it should work. And no, I don't want the file to be sent on every postback. Just if you click an upload button with a file in the upload control, and a user clicks refresh on their browser, the same action is performed and the upload control still is showing HasFile = true. I'm trying to not let the code to add a file run again if a browser refresh is performed after clicking upload.

        modified on Friday, September 26, 2008 3:32 PM

        K 1 Reply Last reply
        0
        • K kenexcelon

          I understand that's how it should work. And no, I don't want the file to be sent on every postback. Just if you click an upload button with a file in the upload control, and a user clicks refresh on their browser, the same action is performed and the upload control still is showing HasFile = true. I'm trying to not let the code to add a file run again if a browser refresh is performed after clicking upload.

          modified on Friday, September 26, 2008 3:32 PM

          K Offline
          K Offline
          kenexcelon
          wrote on last edited by
          #4

          Anyone?

          Revolutionary: Disk drives go round and round.

          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