Currently I have two textboxes & one button, Suppose In One textbox1 i write sandeep gupta after clicking on button in textbox2 Sandeep Gupta is dere using the foll. code-

protected void Button1_Click(object sender, EventArgs e)
    {
        string capitalized = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(TextBox1  .Text);
        TextInfo UsaTextInfo = new CultureInfo("en-US", false).TextInfo;
       TextBox2 .Text  = UsaTextInfo.ToTitleCase(txtName .Text );
    }

I want that Text in textbox1 changes to Sandeep Gupta when i press tab to move to next field. I dont know which event to use, can u tell me!!!

Currently I have two textboxes & one button, Suppose In One textbox1 i write sandeep gupta after clicking on button in textbox2 Sandeep Gupta is dere using the foll. code-

protected void Button1_Click(object sender, EventArgs e)
    {
        string capitalized = CultureInfo.CurrentCulture.TextInfo.ToTitleCase(TextBox1  .Text);
        TextInfo UsaTextInfo = new CultureInfo("en-US", false).TextInfo;
       TextBox2 .Text  = UsaTextInfo.ToTitleCase(txtName .Text );
    }

I want that Text in textbox1 changes to Sandeep Gupta when i press tab to move to next field. I dont know which event to use, can u tell me!!!

Hi Sandeep

1) set Autopostback Property = true of Textbox1
2)

protected Sub Textbox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtNewJobRankSerial.TextChanged
      'USE YOUR CODE.  
TextBox2 .Text  = UsaTextInfo.ToTitleCase(txtName .Text );
    End Sub

Mark as solved if it hepls you!!!

Try this code. It will convert the text into TitleCase using JavaScript.

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

<!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></title>

    <script type="text/javascript" language="javascript">
        function Trim(strIn) {
            strOut = strIn;
            strOut = strOut.replace(/^ */g, "");
            strOut = strOut.replace(/ *$/g, "");
            return strOut;
        }


        function TitleCase(oField) {

            var myValue = oField.value
            var htext = Trim(myValue);
            htext = htext.toLowerCase();

            htext = htext.substr(0, 1).toUpperCase() + htext.substring(1, htext.length);
            for (var i = 1; i < htext.length; i++) {
                if (htext.substr(i, 1) == " ") {
                    while (htext.substr(i, 1) == " ")
                        i++;

                    if (i + 1 < htext.length)
                        htext = htext.substr(0, i) + htext.substr(i, 1).toUpperCase() + htext.substring(i + 1, htext.length);
                    else
                        htext = htext.substr(0, i) + htext.substr(i, 1).toUpperCase();
                }
            }
            return htext;
        }
    
    </script>

</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:TextBox ID="TextBox1" onblur="this.value=TitleCase(this);" runat="server" />
      <asp:TextBox ID="TextBox2" runat="server" />

        </div>
    </form>
</body>
</html>

hi reach,thx very much

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.