• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 487
  • Last Modified:

How to use accents and tildes in an asp.net Form

Hi!

I have an asp.net form where the user writes his name, the probem is that I need to be able to accept accent(eg 'á') and tildes (eg ñ) but when I try to retrieve the text writen, the asp.net form takes out this especial characters.  How can I retrieve this characters? It's worth to say that all the info the user is going to input is in Spanish, thats why I having this problem

E.G

--- Button click action ---
Sub clickAction(Sender As Object, E As eventargs)
     Dim nameVar As String = TextBox1.Text
     Response.Write(nameVar) 'Or any other method I use to take the data
End Sub

--- ASP.NET CONTROLS ---
<asp:Textbox ID="TextBox1" runat="server"/> <asp:Button ID="Button1" Text="SAVE" OnClick="clickAction" runat="server"/>

--- What I get ---

If i write lets say "piña" the form gives me "pia" or if i write "mamá" I get "mam"

I really appreciate any help I can get.
Thanks for your time
0
acolor12
Asked:
acolor12
  • 2
1 Solution
 
fernandonajeraCommented:
You should really check that ASP.NET is stripping your accoutes out. Please put a checkpoint in the code, and using Inspector or Immediate see if the á is gone or not in TextBox1.Text.

Response.Write is not a reliable way to know it, because it is close-related to page charset. You can check if your .aspx file content type is "utf-8":

            <META http-equiv="Content-Type" content="text/html; charset=utf-8">

Change that line if you have it to utf-8 or add it and see if it makes any difference.

VS.NET writes all files in UTF8, so if your .aspx file says "I'm in ISO-8859-1" it is not telling the truth, and IE can make crazy things -- I'm Spanish too.
0
 
acolor12Author Commented:
Thanks a lot for your help, I really appreciate it.

I change as you told me the "ISO-8859-1" for "UTF-8" in both ResponseEncoding and Content

<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1" %>
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="UTF-8" %>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

And that's it. It worked so well

Thanks again
0
 
fernandonajeraCommented:
You're welcome! Be careful with encoding, it can make your life very hard. It "attacks" when you don't expect it. Good luck!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now