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

HtmlInputFile.value cleared after submit.

Hello everyone,

I'm writing a web form to upload files. The page contains a number of
tables to maintain the design(which VS.NET complain at the begin, but I
resolved all of them later), a few HtmlInputFile object and a submit button.
When I press the button, the code behind will save the file if the filename
is not null.

However when I press the button, nothing happened. I set a breakpoint in
the first line of Submit_Click method and found its "value"="" and
"Postedfile"=<undefined>. I've tried to add EnableViewstate=true but it
still don't work.

Can anyone suggest what else I have to check to fix this problem? Any
help would be apperciated.

Thanks in advance.

Regards,
Lau Lei Cheong

Nov 18 '05 #1
3 1423
Hi

In order to upload file in ASP.NET and access it in server-side code, you need
1. Add the enctype="multipart/form-data" name-value attribute to the <form> tag as follows
<form id="Form1" method="post" enctype="multipart/form-data" runat="server"
2. Add runat="server" attribute to the file control
<INPUT type=file id=File1 name=File1 runat="server" /
See details of HOW TO: Upload a File to a Web Server in ASP.NET at
VB.NET: http://support.microsoft.com/default...kb;en-us;32324
C#: http://support.microsoft.com/default...kb;EN-US;32324

Bin Song, MC
Nov 18 '05 #2
I've checked the code and found none of them missing.

Thanks anyway. :)

"Bin Song, MCP" <an*******@discussions.microsoft.com> ¦b¶l¥ó
news:0D**********************************@microsof t.com ¤¤¼¶¼g...
Hi,

In order to upload file in ASP.NET and access it in server-side code, you need: 1. Add the enctype="multipart/form-data" name-value attribute to the <form> tag as follows: <form id="Form1" method="post" enctype="multipart/form-data" runat="server"> 2. Add runat="server" attribute to the file control.
<INPUT type=file id=File1 name=File1 runat="server" />
See details of HOW TO: Upload a File to a Web Server in ASP.NET at:
VB.NET: http://support.microsoft.com/default...b;en-us;323245
C#: http://support.microsoft.com/default...b;EN-US;323246

Bin Song, MCP

Nov 18 '05 #3
I've finally realized where the problem is. The problem, however, is not
shown
on the part I posted.

The missing part is that: The mentioned code is on a large form that there
is not only one button. Therefore except the one which forms' submit action
is linked to others do not get the post data.

Very sorry for my over-simplification of problem.

"Bin Song, MCP" <an*******@discussions.microsoft.com> ¦b¶l¥ó
news:0D**********************************@microsof t.com ¤¤¼¶¼g...
Hi,

In order to upload file in ASP.NET and access it in server-side code, you need: 1. Add the enctype="multipart/form-data" name-value attribute to the <form> tag as follows: <form id="Form1" method="post" enctype="multipart/form-data" runat="server"> 2. Add runat="server" attribute to the file control.
<INPUT type=file id=File1 name=File1 runat="server" />
See details of HOW TO: Upload a File to a Web Server in ASP.NET at:
VB.NET: http://support.microsoft.com/default...b;en-us;323245
C#: http://support.microsoft.com/default...b;EN-US;323246

Bin Song, MCP

Nov 18 '05 #4

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

Similar topics

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. ...
5
by: Ariel Dolan | last post by:
Can I use HtmlInputFile to only get the selected file name but not actually upload the file? Clicking the control's Browse button let's the user select a file. All I need is the HtmlInputFile...
5
by: Grant Harmeyer | last post by:
I have an application that uses FreeTextBox 2.0 (http://www.freetextbox.com). FreeTextBox is a rich text editor that behaves similarly to MS Word. The FreeTextBox control has a button to insert...
2
by: Jeti [work] | last post by:
I have a HTMLInputFile control placed onto the page, and everything works fine, except persisting its state... When user clicks "submit", I check some things on the server, and open the same page,...
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...
3
by: UJ | last post by:
Guys, I know this isn't the appropriate place to post this because it's HTML not ASP.Net but I need some guidance. I have a web page with an HTMLInputFile on it. The person enters the stuff,...
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: 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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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
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,...

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.