473,385 Members | 1,732 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,385 software developers and data experts.

HtmlInputFile during postback..

Hi

In the webform, if a use selects a file to upload and submits the form. But
if page validation fails, the HtmlInputFile loses the filename string and
the user has to re-select the file using the browse button.

Is there any way to persist the postedFile.filename during postback?

Appreciate any help.

Nov 19 '05 #1
5 1565
The value in a <input type=file> is not allowed to be set by the page. The
browser always sets it to blank by default. This is for security, as malicious
websites could seed the control with a path to sensitive data on your machine.

-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

In the webform, if a use selects a file to upload and submits the
form. But if page validation fails, the HtmlInputFile loses the
filename string and the user has to re-select the file using the
browse button.

Is there any way to persist the postedFile.filename during postback?

Appreciate any help.


Nov 19 '05 #2
Are you inserting the runat="server" attribute within the tag itself?

"newmem" <""> wrote in message news:eq**************@TK2MSFTNGP14.phx.gbl...
Hi

In the webform, if a use selects a file to upload and submits the form.
But
if page validation fails, the HtmlInputFile loses the filename string and
the user has to re-select the file using the browse button.

Is there any way to persist the postedFile.filename during postback?

Appreciate any help.

Nov 19 '05 #3
If you are having trouble with retrieving the name of the posted file, or
the location to the posted file, make sure the form in which this control
exists has the enctype="multipart/form-data" as seen below.

<form id="DefaultForm" method="post" runat="server"
enctype="multipart/form-data">
</form>

When you upload your picture, you should be able to access it in your code
behind like this.

HttpPostedFile file = Request.Files["MyFileUpload"];

where the control is <INPUT name="MyFileUpload">

Hopefully I answered the right question for you.
--
Alex Mueller
"newmem" <""> wrote in message news:eq**************@TK2MSFTNGP14.phx.gbl...
Hi

In the webform, if a use selects a file to upload and submits the form. But if page validation fails, the HtmlInputFile loses the filename string and
the user has to re-select the file using the browse button.

Is there any way to persist the postedFile.filename during postback?

Appreciate any help.

Nov 19 '05 #4
Can I use client-side validation ? would the browser retain the value in the
<input type=file> control?
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:29**********************@msnews.microsoft.com ...
The value in a <input type=file> is not allowed to be set by the page. The
browser always sets it to blank by default. This is for security, as malicious websites could seed the control with a path to sensitive data on your machine.
-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

In the webform, if a use selects a file to upload and submits the
form. But if page validation fails, the HtmlInputFile loses the
filename string and the user has to re-select the file using the
browse button.

Is there any way to persist the postedFile.filename during postback?

Appreciate any help.


Nov 19 '05 #5
I've not tried too hard to make this work, but I don't even think client
side script allows you to set the value of the file input. Again, it's a
security risk, so hopefully this won't work for you. Sorry. ;)

-Brock
DevelopMentor
http://staff.develop.com/ballen
Can I use client-side validation ? would the browser retain the value
in the <input type=file> control?

"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:29**********************@msnews.microsoft.com ...
The value in a <input type=file> is not allowed to be set by the
page. The browser always sets it to blank by default. This is for
security, as

malicious
websites could seed the control with a path to sensitive data on your

machine.
-Brock
DevelopMentor
http://staff.develop.com/ballen
Hi

In the webform, if a use selects a file to upload and submits the
form. But if page validation fails, the HtmlInputFile loses the
filename string and the user has to re-select the file using the
browse button.

Is there any way to persist the postedFile.filename during postback?

Appreciate any help.


Nov 19 '05 #6

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

Similar topics

0
by: Frank | last post by:
In my aspx page, I use HtmlInputFile to ask user to select a file. When I select the file and hit submit button, 60% of the time I get "The page cannot be displayed". A postback event didn't...
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. ...
1
by: mravichandran | last post by:
Dear Readers, I am trying to take image files and store them in SQL server. as a 1st step, I am trying to read them from a directory on the network. in the declaration section (below 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...
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...
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...
7
by: cindy | last post by:
I have a System.Web.UI.HtmlControls.HtmlInputFile control that I use to submit files. Before the file is successfully submitted I validate another field on the form, it is the description of the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.