473,405 Members | 2,141 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,405 software developers and data experts.

value="" option on input type="file" in ASP.NET

Hello,

I am uploading a file using this form in ASP.NET. I have also added a
simpel textfield:
<form runat="server" enctype="multipart/form-data">
<input type="file" id="oFile" Name="oFile" size="70" runat="Server">
<input type="text" SIZE="20" MAXLENGTH="20" id="Name" NAME="Name">
<input type="submit" id="Submit" runat="Server" value="Submit"
OnServerClick="SubmitButton_Click">
</form>

I want to do some validation on the textfield "Name". When for example
the field is not filled in or does not contain the correct value, I
want is come back to the form with an error message and already fill in
the previous submitted values (so the user does not need to fill in the
complete form again). No problem so far.

The problem starts when I return to the form and then want to pass the
submitted path back to the oFile field. Something like: <input
type="file" id="oFile" Name="oFile" size="70" runat="Server"
value="<%=sPostedFilePatch%>">

It seems to be impossible to set the "value" option for a input field
with type="file".

How can I make sure that user does NOT have to browse for the file
again when another field than the "oFile" field has a incorrect value.

Thanks

Nov 19 '05 #1
2 5634
IkBenHet wrote:
Hello,

I am uploading a file using this form in ASP.NET. I have also added a
simpel textfield:
<form runat="server" enctype="multipart/form-data">
<input type="file" id="oFile" Name="oFile" size="70" runat="Server">
<input type="text" SIZE="20" MAXLENGTH="20" id="Name" NAME="Name">
<input type="submit" id="Submit" runat="Server" value="Submit"
OnServerClick="SubmitButton_Click">
</form>

I want to do some validation on the textfield "Name". When for example
the field is not filled in or does not contain the correct value, I
want is come back to the form with an error message and already fill
in the previous submitted values (so the user does not need to fill
in the complete form again). No problem so far.

The problem starts when I return to the form and then want to pass the
submitted path back to the oFile field. Something like: <input
type="file" id="oFile" Name="oFile" size="70" runat="Server"
value="<%=sPostedFilePatch%>">

It seems to be impossible to set the "value" option for a input field
with type="file".

How can I make sure that user does NOT have to browse for the file
again when another field than the "oFile" field has a incorrect value.

Thanks


Try to remove the "runat=server". As a security precaution, you *can't* set
the value for a fileinput.

Hans Kesting
Nov 19 '05 #2
You can't set programmatically this value for safety reasons (it would allow
to pick files on client machine without the user permission).

Possible workarounds :
- change the UI
- validate client side
- validate server side without refreshing the page (IFRAME, XMLHTTP)
- others ?

Patrice

--

"IkBenHet" <ik********@hotmail.com> a écrit dans le message de
news:11*********************@g43g2000cwa.googlegro ups.com...
Hello,

I am uploading a file using this form in ASP.NET. I have also added a
simpel textfield:
<form runat="server" enctype="multipart/form-data">
<input type="file" id="oFile" Name="oFile" size="70" runat="Server">
<input type="text" SIZE="20" MAXLENGTH="20" id="Name" NAME="Name">
<input type="submit" id="Submit" runat="Server" value="Submit"
OnServerClick="SubmitButton_Click">
</form>

I want to do some validation on the textfield "Name". When for example
the field is not filled in or does not contain the correct value, I
want is come back to the form with an error message and already fill in
the previous submitted values (so the user does not need to fill in the
complete form again). No problem so far.

The problem starts when I return to the form and then want to pass the
submitted path back to the oFile field. Something like: <input
type="file" id="oFile" Name="oFile" size="70" runat="Server"
value="<%=sPostedFilePatch%>">

It seems to be impossible to set the "value" option for a input field
with type="file".

How can I make sure that user does NOT have to browse for the file
again when another field than the "oFile" field has a incorrect value.

Thanks

Nov 19 '05 #3

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

Similar topics

1
by: Jesper Hermansen | last post by:
Hi! I'm making a system that will generate Winamp-playlists. To make it easy for the user to add a file to the list, I'm using <input type="file">. The problem with this is that I only get...
2
by: Matt | last post by:
If I do the following, the browse text box still cannot see C:/hello world/test.txt. <input type="file" name="fileName" value="C:/hello world/test.txt" size=80> Any ideas? and workarounds...
5
by: Mr Gordonz | last post by:
Hi all, I want to put a button on a page, and when the user clicks it, the standard Windows "Open File" dialogue box opens, and the user can browse/select a file on their PC. Having selected a...
1
by: Mark Sandfox | last post by:
Is there a way to restrict the user to only selecting and sending either a ..gif or .jpg. Everything I have read says this option can not be done by design (security reasons). I find that irronic...
4
by: kevin | last post by:
Hi, I am trying to create a page so the user can browse the network, select a file and have that file name (text) inserted into our sql DB so I can build the hyperlink path later on. Here's what...
9
by: Prakash Singh Bhakuni | last post by:
am replacing the default "Browse..." button for input type=file. This works fine except that the form will only submit after the SUBMIT button is clicked twice. Any ideas on why this is happening...
3
by: eeeeman | last post by:
This one has really got me! Im trying to write a value to a input type="file" form element using client-side javascript. I have tried the obvious, simply writing: <input type="file" ...
1
by: ChollaPete | last post by:
This code: <form action="processScan.php" method="get"> <p> <?php print "Scan name: <input type=\"file\" name=\"tScanFileName\" value= \"{$scanFileName}\"><br>"; addHiddenCarryons(); ?>...
1
by: sandeep kumar shah | last post by:
Hi, We have used a file uploading HTML tag in an HTML page. We need to customize the text displayed on the Button (which is by default “Browse…” for internet explorer). Below is the...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.