How to use accents and tildes in an Form

Posted on 2005-04-22
Last Modified: 2012-06-27

I have an 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 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


--- 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: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
Question by:acolor12
    LVL 4

    Accepted Solution

    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.

    Author Comment

    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
    LVL 4

    Expert Comment

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

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
    If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
    This video discusses moving either the default database or any database to a new volume.
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    732 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now