Step in CSS! There is a CSS property text-transform, which can be either capitalize, lowercase or uppercase. What this will do will force the text entered to display as capitalized, lowercase or uppercase (whatever you choose). Now, this looked like a winner, as there was no scripting needed. However, this only does half the job. All the CSS class will do is display what is entered as uppercase, not actually convert it to uppercase.
The fix… when you get the text from the textbox in your codebehind, use the .ToUpper() method to convert the entered text to uppercase.
- Add a CSS class with text-transform: uppercase;
- Add this CSS class to any textbox you want to have uppercase text.
- When getting the text from the textbox, use the .ToUpper() method to convert the text to uppercase.
I hope someone else finds this helpful.