Posting from HTML form to WebForm

G

Guest

I am posting from a HTML form (below) to a aspx webform.
This works OK but I notice the £ character (pound sign) is dropped! i.e. not
picked up by a Request.Form["X"] in the webform e.g. input = 12£34, output =
1234

Please would anyone say why this is?

<body>
<form name="Form1" method="post" action="WebForm3.aspx" id="Form1">
<input name="X" type="text" id="X">
<input type="submit" name="Button1" value="TheButton" id="Button1" >
</form>
</body>
 
S

Steve C. Orr [MVP, MCSD]

Have you tried setting it to use unicode?
Here's more info on the subject:
http://msdn.microsoft.com/library/d...en-us/cpguide/html/cpconencodingbasetypes.asp

Also, have you checked the Globalization section of the web.config?
Try changing it to something more like this:

<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
<globalization
fileEncoding="iso-8859-1"
requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1"
/>
</system.web>
</configuration>
 
J

Joerg Jooss

Steve said:
Have you tried setting it to use unicode?
Here's more info on the subject:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgui
de/html/cpconencodingbasetypes.asp

Also, have you checked the Globalization section of the web.config?
Try changing it to something more like this:

<!-- Web.Config Configuration File -->

<configuration>
<system.web>
<customErrors mode="Off"/>
<globalization
fileEncoding="iso-8859-1"
requestEncoding="iso-8859-1"
responseEncoding="iso-8859-1"
/>
</system.web>
</configuration>

ISO-8859-1 is *not* Unicode.

The problem is that the HTML page uses its own encoding to submit the
data, which unless specified is ISO-8859-1. So either change the
globalization element (this can also be done by code BTW), or encode
the HTML page properly, i.e. save it with UTF-8 encoding and add a
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
tag to the page.

Note that there's little reason to downgrade requestEncoding and
responseEncoding from UTF-8 unless every single byte transmitted
counts, or content is solely intended for North American or Western
European users (excluding the French, who forgot to include some
characters in ISO-8859-1 ;->). I recommend encoding the HTML page
instead.

In theory, the form tag's "accept-charset" attribute allows one to
specify the encoding of form data regardless of the page's own encoding
or browsers settings, but this attribute lacks proper browser support.

Cheers,
 
G

Guest

Marvelous and thank you very much.

Joerg Jooss said:
ISO-8859-1 is *not* Unicode.

The problem is that the HTML page uses its own encoding to submit the
data, which unless specified is ISO-8859-1. So either change the
globalization element (this can also be done by code BTW), or encode
the HTML page properly, i.e. save it with UTF-8 encoding and add a
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
tag to the page.

Note that there's little reason to downgrade requestEncoding and
responseEncoding from UTF-8 unless every single byte transmitted
counts, or content is solely intended for North American or Western
European users (excluding the French, who forgot to include some
characters in ISO-8859-1 ;->). I recommend encoding the HTML page
instead.

In theory, the form tag's "accept-charset" attribute allows one to
specify the encoding of form data regardless of the page's own encoding
or browsers settings, but this attribute lacks proper browser support.

Cheers,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top