473,406 Members | 2,369 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

How to Persist HtmlInputFile Value through postback?

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
Nov 20 '05 #1
3 4533
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" <dc*****@adlercomputing.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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

Nov 20 '05 #2
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" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
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" <dc*****@adlercomputing.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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


Nov 20 '05 #3
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" <dc*****@adlercomputing.com> wrote in message
news:u0**************@TK2MSFTNGP12.phx.gbl...
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" <no****@blowgoats.com> wrote in message
news:10*************@corp.supernews.com...
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" <dc*****@adlercomputing.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
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



Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Paul Perot | last post by:
Hi All: I have a DataTable that I have defined Globally. I populate this datatable dynamically with file/folder information that I read directly from the server. I use this datatable...
7
by: Al Smith | last post by:
Newbee to aspx needs direction. We are using an <INPUT type="file" tag to upload a file. We also have a text field for the user to enter a description for the file which the user must enter. ...
3
by: Dave Adler | last post by:
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...
2
by: Augusto Cesar via DotNetMonster.com | last post by:
Hi, I want to customize the HtmlInputFile. I wanna something like an image button to play the "browse" button hole and hide the textbox. Is that possible? I also have tried to hide an...
7
by: Buddy Ackerman | last post by:
I created this class Public Class HTMLFileInput : Inherits System.Web.UI.HtmlControls.HtmlInputFile Public Property Data As String Get Return ViewState("HTMLFileInput.Data") End Get Set...
1
by: Owen | last post by:
Firstly, if this is the wrong newsgroup for my question, please direct me elswhere and accept my apologies! It's a question about ASP.NET but also uses VB.NET classes. This is a little...
1
by: nes | last post by:
Hi all, For uploading files i am using the HtmlInputFile. Now I want to do 2 things with it. First I want to give the button a specific style and second when a postback happens I don't want the...
8
by: Nathan Sokalski | last post by:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to submit files. After the file is successfully submitted, I want the field to be reset so that the user knows the file was...
10
by: Carlos | last post by:
Hi all, I have a form with an input radio control in a template field. When the user selects an option, and press a button the selection disappears.. I would like the selection to persist after...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.