UpperCase textbox

Posted on 2009-02-08
Last Modified: 2013-12-14
I need all the text fields (textbox) from my form to be filled with text in uppercase, but not found any property on textbox component to do that, you can help me?

I use textbox on ASP.NET webpage.
Question by:fsouzabrasil
    LVL 25

    Expert Comment

    Use the UCASE() function!
    LVL 4

    Author Comment

    yes, on code i use textbox.toUpper(), but when user write on textbox i need display uppercase chars.

    LVL 69

    Expert Comment

    by:Éric Moreau
    LVL 25

    Expert Comment

    An alternative is to use the Change event for the control to convert the contents by using <control>.toUpper()
    LVL 16

    Accepted Solution

    You can add attributes to the textbox to do this using javascript
    txtBox.Attributes.Add("onkeyup", "this.value=this.value.toUpperCase();");
    txtBox.Attributes.Add("onblur", "this.value=this.value.toUpperCase();");
    or you can do it in code behind
    string text = txtBox.Text.toUpper();

    Open in new window

    LVL 27

    Expert Comment

    CSS's the way to go:

    <asp:TextBox ID="testBox" runat="server" CssClass="uCase" />
        text-transform: uppercase;

    Open in new window


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Better Security Awareness With Threat Intelligence

    See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
    This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
    The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

    758 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

    10 Experts available now in Live!

    Get 1:1 Help Now