PC Review


Reply
Thread Tools Rating: Thread Rating: 2 votes, 3.00 average.

How to Persist HtmlInputFile Value through postback?

 
 
Dave Adler
Guest
Posts: n/a
 
      18th Feb 2004
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


 
Reply With Quote
 
 
 
 
CJ Taylor
Guest
Posts: n/a
 
      18th Feb 2004
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
 
 
 
Dave Adler
Guest
Posts: n/a
 
      18th Feb 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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
> >
> >

>
>



 
Reply With Quote
 
CJ Taylor
Guest
Posts: n/a
 
      18th Feb 2004
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> > > 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
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Initial value of HtmlInputFile Dotnet Microsoft ASP .NET 2 13th Jan 2005 04:50 PM
Re: HtmlInputFile losing value after postback bruce barker Microsoft ASP .NET 0 4th Aug 2004 05:18 PM
HtmlInputFile.value cleared after submit. Lau Lei Cheong Microsoft ASP .NET 3 19th May 2004 03:28 AM
How to Persist HtmlInputFile Value through postback? Dave Adler Microsoft ASP .NET 3 18th Feb 2004 10:18 PM
Cant set value of HTMLInputFile control Mark Microsoft ASP .NET 2 9th Nov 2003 08:37 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:36 PM.