|
Capitalize First Letter Of Every Word In Asp.Net
|
Force the first letter of every word to upper case in ASP.net in one line of code.
Features
Programming: ASP.net
|
Technology: How-To
|
Technology: Tips & Tricks
|
Programming: VB
| |
Want to capitalize the first letter of every word in a string using asp.net? It's easy to do using asp.net! My code is all in VB but you can easily convert it to C# as needed.
If you have a string like "hello world" you would simply do this...
System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase("hello world")
Which would output...
Hello World
If you want to be able to easily re-use this code, drop it into a function that you can call easily without having to remember the entire line of code. I use this...
Shared Function format_capitalize_first_letter_each_word(string_in As String) As String
Dim sr As String = System.Threading.Thread.CurrentThread.CurrentCulture.TextInfo.ToTitleCase(string_in)
Return sr.ToString
End Function
Disclaimer: We're not affiliated, authorized, associated, endorsed by, or officially connected with the company or entities listed here, or any of their subsidiaries or affiliates. All trademarks cited, listed, or shown here are the property of their respective owners. We are not responsible for errors, omissions,
safety issues, or inaccurate information. This site is for entertainment purposes only and is not an official guide. Attempting anything you see here is done so at your own risk and we are not responsible for your safety, loss of life, legal or medical fees, or damages because of anything you see or read on this site.
All information and content provided on this site is for educational, informational, and entertainment purposes only. Always consult a professional before following any information you read here. See our Terms and Conditions for more information.