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

multipart/form-data problem

Hello,

I have a really weird problem I've been trying to solve it without any luck
for the last couple of hours :(
I'm writing a "conference board" application (quite similar to ASP.NET
forum).
I don't use server controls in it (apart from Page).

The problem occurs on the page where visitor can post a new messages.
Basically, it's a form with couple of
edit controls, hidden fields, buttons and and a file upload control. Form
enctype is multipart/form-data (to enable file uploads)
The first 5 fields after <FORM> is hidden fields (Thats important!) When
user post that form I use Request.Params to extract required data.

The problem appeared after I added two checkbox controls at the end of the
form.

Now, if user types-in anything using multibyte encoding (i.e. in jewish,
arabic, ... or just special characters) and posts the form the 1st hidden
field
will go missing when I try to access it via Request.Params. Only 1st one -
all other fields will be just fine.

If I remove enctype="multipart/form-data" it will work fine. If I remove
last checkboxes it will work fine.
If I'll just use English it will work fine.

I understand it's very lengthy explanation and probably a bit confusing, but
I really stuck on this one.

I would appreciate any help and will be happy provide addiitonal information
if required.

Thanks in advance.

Alex


Nov 18 '05 #1
4 4549
Is there a reason you are using Request.Param instead of the asp.net method
of using web or html controls? You should try it and see if it'll fix your
problem.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
"Alex Sibilev" <NO********@sql.ru> wrote in message
news:Oh**************@TK2MSFTNGP12.phx.gbl...
Hello,

I have a really weird problem I've been trying to solve it without any luck for the last couple of hours :(
I'm writing a "conference board" application (quite similar to ASP.NET
forum).
I don't use server controls in it (apart from Page).

The problem occurs on the page where visitor can post a new messages.
Basically, it's a form with couple of
edit controls, hidden fields, buttons and and a file upload control. Form enctype is multipart/form-data (to enable file uploads)
The first 5 fields after <FORM> is hidden fields (Thats important!) When user post that form I use Request.Params to extract required data.

The problem appeared after I added two checkbox controls at the end of the form.

Now, if user types-in anything using multibyte encoding (i.e. in jewish,
arabic, ... or just special characters) and posts the form the 1st hidden
field
will go missing when I try to access it via Request.Params. Only 1st one - all other fields will be just fine.

If I remove enctype="multipart/form-data" it will work fine. If I remove
last checkboxes it will work fine.
If I'll just use English it will work fine.

I understand it's very lengthy explanation and probably a bit confusing, but I really stuck on this one.

I would appreciate any help and will be happy provide addiitonal information if required.

Thanks in advance.

Alex

Nov 18 '05 #2
Thanks for reply Karl,

I have my own html template processor and trying to squeeze from ASP.NET
everything I can, performance wise.
So I turned off Viewstate, AutoEventWireUp and using basic Request.Params &
Forms to get posted data.

Also I noticed more weird behaviour today. In my HTML I've got fields in
this order:
<form>
hidden fields
entry fields (text, textarea, radio)
submit buttons
checkboxes
</form>

Now, if I swap submit buttons with checkboxes it all starts to work. It
really driving me nuts.

Alex

"Karl" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net> wrote in
message news:eW**************@TK2MSFTNGP11.phx.gbl...
Is there a reason you are using Request.Param instead of the asp.net
method
of using web or html controls? You should try it and see if it'll fix
your
problem.

Karl

Nov 18 '05 #3
I suppose in the meanwhile you solved the problem already, but since
I've been experiencing the same problem I'm going to post something
here anyway ;) (it may be useful still). The trouble here is this:

When you change the enctype to "multipart/form-data", you change the
way the form is sent, and apparantly it doesn't support the
checkboxes. The "multipart/form-data"-enctype neglects everything in
the code that is written under the submit-button. From there the
enctype automaticly changes back to the defauld
"application/x-www-form-urlencoded", so thats why the checkboxes will
work properly when situated under the submit.

Since locating the checkboxes únder the submit-button looks stupid, I
didn't accept this as a solution. This is the way I díd solve it:
I created a form inside a form. I didn't really expect it to work, but
it accually did :D. This is how it works:
Instead of this:

<form enctype="multipart/form-data" action="asppage.asp"
method="post">

<input type="file" name="file">
<input type="checkbox" name="checkbox">

<input type="submit">
</form>

I wrote this:

<form enctype="multipart/form-data" action="asppage.asp"
method="post">

<input type="file" name="file">
<form>
<input type="checkbox" name="checkbox">

<input type="submit">
</form>
</form>

This worked for me. All data was send and I was able to use it the way
wanted it to. I'm not sure it will work for everyone else having this
problem, but else you could always try to use dropdowns-menues with
yes/no inside them. I suppose that'll work also but it'll look less
good :P.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 18 '05 #4
Hi Unit,

You have some basic misunderstandings here. I hope I can clear them up for
you.
When you change the enctype to "multipart/form-data", you change the
way the form is sent, and apparantly it doesn't support the
checkboxes. The "multipart/form-data"-enctype neglects everything in
the code that is written under the submit-button. From there the
enctype automaticly changes back to the defauld
"application/x-www-form-urlencoded", so thats why the checkboxes will
work properly when situated under the submit.
This is all incorrect. Remember that we're talking about an HTML document
here, as far as the form is concerned. An HTML form can have only ONE
encoding type. That is defined in the form tag. If the enctype attribute is
set to "multipart/form-data," the entire form is encoded in that way. It has
nothing to do with any submit button, or checkboxes, or anything else except
the "enctype" tag. Everything in the form is encoded in the same way. Note
that I said "everything in the form." You can have more than one form on a
page. When a form submits, it doesn't submit the page, but only the form
fields contained within that form. So, you might want to check whether or
not you have more than one form on the page, or if some of the form fields
are outside of the form.

Checkbox data is indeed sent with the rest of the form data. I don't know
why you can't seem to get the data from the CheckBox, as you didn't describe
the issue you're having.
Since locating the checkboxes únder the submit-button looks stupid, I
didn't accept this as a solution. This is the way I díd solve it:
I created a form inside a form. I didn't really expect it to work, but
it accually did :D. This is how it works:
Your solution may have worked on the browser you tested it on, but it is not
right. You cannot nest forms in HTML. Well, as you have discovered, you CAN,
but it is a violation of the W3C standard to do so, and may produce
unexpected results depending upon the browser. In any case, it's a hack. And
it will bite you at some point.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Unit" <m.****@chello-dot-nl.no-spam.invalid> wrote in message
news:41**********@Usenet.com... I suppose in the meanwhile you solved the problem already, but since
I've been experiencing the same problem I'm going to post something
here anyway ;) (it may be useful still). The trouble here is this:

When you change the enctype to "multipart/form-data", you change the
way the form is sent, and apparantly it doesn't support the
checkboxes. The "multipart/form-data"-enctype neglects everything in
the code that is written under the submit-button. From there the
enctype automaticly changes back to the defauld
"application/x-www-form-urlencoded", so thats why the checkboxes will
work properly when situated under the submit.

Since locating the checkboxes únder the submit-button looks stupid, I
didn't accept this as a solution. This is the way I díd solve it:
I created a form inside a form. I didn't really expect it to work, but
it accually did :D. This is how it works:
Instead of this:

<form enctype="multipart/form-data" action="asppage.asp"
method="post">

<input type="file" name="file">
<input type="checkbox" name="checkbox">

<input type="submit">
</form>

I wrote this:

<form enctype="multipart/form-data" action="asppage.asp"
method="post">

<input type="file" name="file">
<form>
<input type="checkbox" name="checkbox">

<input type="submit">
</form>
</form>

This worked for me. All data was send and I was able to use it the way
wanted it to. I'm not sure it will work for everyone else having this
problem, but else you could always try to use dropdowns-menues with
yes/no inside them. I suppose that'll work also but it'll look less
good :P.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Nov 18 '05 #5

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

Similar topics

2
by: Damien | last post by:
Hi to all, After hours of attempts and "googling", I'm still pulling my hair off my head when I try to send multipart html emails. It "works" on PCs with Outlook when I juste send a single...
5
by: lucanos | last post by:
Hey All, I'm having trouble trying to create a PHP file which will generate a multipart email message (containing both an HTML formatted part and a Plain Text formatted part). I have Googled...
4
by: Hunter Peress | last post by:
I have been unable to write a script that can do (and receieve) a multipart form upload. Also, it seems that there really are differences between python's implementation and else's. Can someone...
0
by: Travis Pupkin | last post by:
Hi, I have a form that triggers the sending of an e-mail via CDOSYS. I'd like to make this a nice HTML-formatted multipart message, but for some reason the text version is coming through blank....
3
by: c# newbie | last post by:
System.Web.Mail.MailFormat The enumerated values for MailFormat are: Html Text How can I send a multipart/alternative format message ?
4
by: John Fereira | last post by:
So, one of the limitations of multipart-form handling is that when an <input type="file" ..> tag is used it will bring up a window which allows a user to select a file for upload but won't allow...
0
by: Werner Maier | last post by:
Hi please can anybody help me to read a WEB side with Content-Type: multipart/x-mixed-replace ("Server Push") . I am a absolutly newbie with c# .net. i have problems to read the boundarys to...
3
by: Li Zhang | last post by:
I know I can use controlName.Value to retrieve the form fields value if I am in that page. But if I am out of the page, for example I am in a HttpModule, I want to retrieve a hidden filed value, Is...
2
by: Der tolle Emil | last post by:
Hi! I wrote a little function to send emails which works quite well. I already managed to send attachments correctly (also more than 1 per email) but I am not able to send a HTML mail containing...
4
by: yoram.ayalon | last post by:
Hi, I need to create a multipart request to UPS manifest upload electronic service. UPS wants the request to consist of a series of headers and bodies, and its not clear how can I use the...
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
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
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.