Convert string to upper, lower and title case in asp .net

In this asp .net tutorial we will learn how to convert string into upper case, lower case and to title case.we will use inbuilt .net methods to convert the string to lower, upper and title case.
 

Step1: Create a new asp .net website.


Step2: Add following HTML Code to your default.aspx page.

Enter Text

This HTML Code will create following output: 


Convert-string-to-upper-lower-and-title-case-in-asp-net

 

Convert String To Lower:

Write following code to button "btnToLower" click event. This code will convert string to lower case.

 

//==== BtnToLower to convert entered text to lower case
    protected void btnToLower_Click(object sender, EventArgs e)
    {
        string txt = txtTextToConvert.Text.Trim();
        lblResult.Text = txt.ToLower();
    }

 

Convert String To Upper:

Write following code to button "btnToUpper" click event. This code will convert string to lower case.

 

//==== BtnUpper to convert entered text to Upper case
    protected void btnToUpper_Click(object sender, EventArgs e)
    {
        string txt = txtTextToConvert.Text.Trim();
        lblResult.Text = txt.ToUpper();
    }

 

Convert String To Title:


Add Following Namespaces: 


using System.Globalization;
using System.Threading;


Write following code to button "btnToProper" click event. This code will convert string to lower case.

//==== BtnProper to convert entered text to proper case
    protected void btnToProper_Click(object sender, EventArgs e)
    {
        string txt = txtTextToConvert.Text.Trim();
        CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
        TextInfo ti = cultureInfo.TextInfo;
        lblResult.Text = ti.ToTitleCase(txt);
    }

 

Final Output:


String-To-Lower-upper-title-case-in-asp-net
 

 
We are nothing without our users ! You can help us offer even more high quality content. Please share our page !
Best quality Asp .Net Ajax Control Toolkit tutorials.

Give your valuable comments.

Name
Email
Comment
6 + 7 =
 
About Us | Terms of Use | Privacy Policy | Disclaimer | Contact Us Copyright © 2012-2019 CodingFusion
75 Important SQL Server queries you should know