472,363 Members | 1,981 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,363 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 5532
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...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...

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.