How to Persist HtmlInputFile Value through postback?

Discussion in 'Microsoft VB .NET' started by Dave Adler, Feb 18, 2004.

  1. Dave Adler

    Dave Adler Guest

    Is there any way to retain the value of an HtmlInputFile control through a
    postback?

    I do some server side validation on the page when it is submitted and if an
    error occurs on the page the HtmlInputFile control value is blank after the
    postback. The EnableViewState for the control is set to true. I can't put
    the postedFile.filename value in a hidden control and then put it back into
    the HtmlInputFile control on postback because the postedFile.filename and
    the value properties are read-only.

    Any ideas?

    Thanks in advance

    David
     
    Dave Adler, Feb 18, 2004
    #1
    1. Advertisements

  2. Dave Adler

    CJ Taylor Guest

    HtmlInputFile does a lot more than just a "textbox" which is why its read
    only.

    You have to save that file and then use a label at that point, otherwise
    your just wasting bandwidth.

    2) You don't know the name of the file on the users end do you? Of course
    you don't, just the file name, not the dirs or anything.


    "Dave Adler" <> wrote in message
    news:%...
    > Is there any way to retain the value of an HtmlInputFile control through a
    > postback?
    >
    > I do some server side validation on the page when it is submitted and if

    an
    > error occurs on the page the HtmlInputFile control value is blank after

    the
    > postback. The EnableViewState for the control is set to true. I can't put
    > the postedFile.filename value in a hidden control and then put it back

    into
    > the HtmlInputFile control on postback because the postedFile.filename and
    > the value properties are read-only.
    >
    > Any ideas?
    >
    > Thanks in advance
    >
    > David
    >
    >
     
    CJ Taylor, Feb 18, 2004
    #2
    1. Advertisements

  3. Dave Adler

    Dave Adler Guest

    Well here is the deal. I have multiple HtmlInputFile controls on a single
    form. I also have other input controls on the form. In my validation
    routine, I check to see if the user checked a checkbox control to overwrite
    existing files. If it is not checked, I verify that the filenames of the
    files the user elected to upload are not the same as files in the upload
    directory. If they are the same, I put a descriptive error message on the
    page that identifies which file is exsiting and what action to take.
    However, since the HtmlInputFile control does not retain its selected file
    during postback, the user has to reselect all of the files he wants to
    upload in order to to resubmit the form.

    I was hoping that I could use the multiple file upload approach as opposed
    to a single upload but this issue removes any advantage if the user has to
    reselect multiple files each time there is a postback.

    Thanks for your feedback though.

    David

    "CJ Taylor" <> wrote in message
    news:...
    > HtmlInputFile does a lot more than just a "textbox" which is why its read
    > only.
    >
    > You have to save that file and then use a label at that point, otherwise
    > your just wasting bandwidth.
    >
    > 2) You don't know the name of the file on the users end do you? Of

    course
    > you don't, just the file name, not the dirs or anything.
    >
    >
    > "Dave Adler" <> wrote in message
    > news:%...
    > > Is there any way to retain the value of an HtmlInputFile control through

    a
    > > postback?
    > >
    > > I do some server side validation on the page when it is submitted and if

    > an
    > > error occurs on the page the HtmlInputFile control value is blank after

    > the
    > > postback. The EnableViewState for the control is set to true. I can't

    put
    > > the postedFile.filename value in a hidden control and then put it back

    > into
    > > the HtmlInputFile control on postback because the postedFile.filename

    and
    > > the value properties are read-only.
    > >
    > > Any ideas?
    > >
    > > Thanks in advance
    > >
    > > David
    > >
    > >

    >
    >
     
    Dave Adler, Feb 18, 2004
    #3
  4. Dave Adler

    CJ Taylor Guest

    Whats to say that you have to do it all in one "shebang" like this.

    If the user uploads the files, and some exist, no one said you have to save
    it in that directory right at that moment. You can place them in a temp
    directory, send the filenames back on the postback (not requiring to be
    resubmitted) and then give the user the option to do whatever they want with
    those files with like checkboxes or some other control.

    Then on each consectutive postback, you don't have any files to transfer
    because they are already server side, making your post backs faster, less
    hassle on you users, and a more effecient web program.

    HTH,
    CJ

    "You know how I know I'm nerd? Most people have trophies, I have a
    USRobotics Courier external modem on my mantle." -CJ Taylor


    "Dave Adler" <> wrote in message
    news:...
    > Well here is the deal. I have multiple HtmlInputFile controls on a single
    > form. I also have other input controls on the form. In my validation
    > routine, I check to see if the user checked a checkbox control to

    overwrite
    > existing files. If it is not checked, I verify that the filenames of the
    > files the user elected to upload are not the same as files in the upload
    > directory. If they are the same, I put a descriptive error message on the
    > page that identifies which file is exsiting and what action to take.
    > However, since the HtmlInputFile control does not retain its selected file
    > during postback, the user has to reselect all of the files he wants to
    > upload in order to to resubmit the form.
    >
    > I was hoping that I could use the multiple file upload approach as opposed
    > to a single upload but this issue removes any advantage if the user has to
    > reselect multiple files each time there is a postback.
    >
    > Thanks for your feedback though.
    >
    > David
    >
    > "CJ Taylor" <> wrote in message
    > news:...
    > > HtmlInputFile does a lot more than just a "textbox" which is why its

    read
    > > only.
    > >
    > > You have to save that file and then use a label at that point, otherwise
    > > your just wasting bandwidth.
    > >
    > > 2) You don't know the name of the file on the users end do you? Of

    > course
    > > you don't, just the file name, not the dirs or anything.
    > >
    > >
    > > "Dave Adler" <> wrote in message
    > > news:%...
    > > > Is there any way to retain the value of an HtmlInputFile control

    through
    > a
    > > > postback?
    > > >
    > > > I do some server side validation on the page when it is submitted and

    if
    > > an
    > > > error occurs on the page the HtmlInputFile control value is blank

    after
    > > the
    > > > postback. The EnableViewState for the control is set to true. I can't

    > put
    > > > the postedFile.filename value in a hidden control and then put it back

    > > into
    > > > the HtmlInputFile control on postback because the postedFile.filename

    > and
    > > > the value properties are read-only.
    > > >
    > > > Any ideas?
    > > >
    > > > Thanks in advance
    > > >
    > > > David
    > > >
    > > >

    > >
    > >

    >
    >
     
    CJ Taylor, Feb 18, 2004
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Kurt

    How to persist dynamic controls

    Kurt, Oct 1, 2003, in forum: Microsoft VB .NET
    Replies:
    2
    Views:
    165
    Fergus Cooney
    Oct 6, 2003
  2. John Mason

    Restricting file types in HtmlInputFile

    John Mason, Dec 16, 2003, in forum: Microsoft VB .NET
    Replies:
    1
    Views:
    208
    Herfried K. Wagner [MVP]
    Dec 16, 2003
  3. Antonio
    Replies:
    0
    Views:
    212
    Antonio
    Jan 13, 2005
  4. Nathan Sokalski
    Replies:
    8
    Views:
    176
    Guest
    May 23, 2006
  5. Mythran

    Persist Other Properties On Property Value Change

    Mythran, Aug 22, 2006, in forum: Microsoft VB .NET
    Replies:
    0
    Views:
    165
    Mythran
    Aug 22, 2006
Loading...

Share This Page