You must Sign In to post a response.
  • Category: ASP.NET

    Automatically small letter change to Capital Letter in Textbox

    Hi frineds,

    I create one web page using ASP.Net...if user enter small letter in that page text box automatically that letter changes to capital immediately(without server side code)..is it possible? how can i achieve that in asp.net?
  • #573481
    private void Button_Click(object sender, EventArgs e)
    {
    string str1 = string.Empty;
    str1 = textbox1.Text;
    char char1;
    if (str1 != string.Empty)
    {
    char1 = Char.ToUpper(str1[0]);
    textbox2.Text = char1.ToString();
    }
    }

    Thanks

    Reena

  • #573484
    Hi Friend,
    Yes Possible.Using Java script you can solve your problem.

    Using toUpperCase() function we will change the lower case letter to upper case.

    Example:-

    1)File ->New Web Site->Choose ASP.net Web Site
    2)Give name for Project and choose your language either C# or VB.net then click ok button.
    3)Just drag and drop one text box control to your page.
    4)Onkeyup event of Textbox control call the toupper java script function.This function will change the lower case letter to upper case.



    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    <title>Untitled Page</title>
    <script type="text/javascript">
    function toUpper(txt)
    {
    document.getElementById(txt).value=document.getElementById(txt).value.toUpperCase();
    return true;
    }
    </script>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <asp:TextBox ID="TextBox1" onkeyup="return toUpper(this.id)" runat="server"></asp:TextBox>
    </div>
    </form>
    </body>
    </html>




    Thanks & Regards
    G.Renganathan
    Nothing is mine ,Everything is yours!!!

  • #573488
    Try following code

    <head runat="server">
    <title></title>
    <script type="text/javascript">
    function Check(txt) {
    document.getElementById(txt).value = document.getElementById(txt).value.toUpperCase();
    }
    </script>
    </head>
    <body>
    <form id="form1" runat="server">
    <div>
    <input type="text" value="" id="txtData" onkeypress="Check(this.id)" />
    </div>
    </form>
    </body>

  • #573499
    Thanks rengan,poonam,manisha..

    renga your coding working well thanks for breif explanation...

    Regards
    N.Ravindran
    Your Hard work never fails


  • This thread is locked for new responses. Please post your comments and questions as a separate thread.
    If required, refer to the URL of this page in your new post.