7 February 2014

Uppercase letters in Asp.net textbox



         Sometime we may need to have upper cases in the textbox, below is the sample to convert all letters to upper case while typing in textbox

method-1:

<asp:TextBox ID="TextBox1" Style="text-transform: uppercase" runat="server" Text="test"></asp:TextBox>

method-2:

<style type="text/css">
.upprcse
{
text-transform: uppercase;
}
</style>

<asp:TextBox ID="TextBox1" CssClass="upprcse" runat="server" Text="test"></asp:TextBox>

Example

<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="Default.aspx.cs" Inherits="_Default" %>

<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
    <center>
        <br />
        <asp:TextBox ID="TextBox1" Style="text-transform: uppercase" runat="server" Text="test"></asp:TextBox>
        <br />
        <br />
        <style type="text/css">
            .upprcse
            {
                text-transform: uppercase;
            }
        </style>
        <asp:TextBox ID="TextBox2" CssClass="upprcse" runat="server" Text="test"></asp:TextBox>
    </center>
</asp:Content>

Output

No comments:

Post a Comment