Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > value="" option on input type="file" in ASP.NET

Reply
Thread Tools

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

 
 
IkBenHet
Guest
Posts: n/a
 
      06-28-2005
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

 
Reply With Quote
 
 
 
 
Hans Kesting
Guest
Posts: n/a
 
      06-28-2005
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


 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      06-28-2005
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" <(E-Mail Removed)> a écrit dans le message de
news:(E-Mail Removed) 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
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

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
Regex for <option> ... </option> John Perl Misc 10 01-29-2009 11:04 PM
page.aspx?option - how to detect "option" Kevin Blount ASP .Net 6 11-28-2006 09:21 PM
DHCP relay agent versus Option 3; Routers Option lcorrigan Cisco 2 09-27-2006 05:18 PM
no 'option' in aspx file means 'option'="false"? Cas ASP .Net 5 08-28-2006 10:36 AM
g++ -pg option and -shared option Julien ROUZIERES C++ 1 12-21-2004 02:30 PM



Advertisments