Solved

Convert text to Uppercase in CSS using ASP.NET

Posted on 2013-06-28
5
591 Views
Last Modified: 2013-08-19
Hello Experts,

I'm creating an ASP.NET Web Form. I would like to have all input by user to be converted to Uppercase which I have been able to do so far, but when the text gets added to the database it gets added however the user inputs it. In other words it's not getting inputed into the database as uppercase.

Is there anyway I can make sure that all data entered in the form is shown and uppercase and then when added to database it gets added as uppercase as well?
0
Comment
Question by:asp_net2
5 Comments
 
LVL 9

Expert Comment

by:Ishaan Rawat
ID: 39286191
use text-transform: uppercase int the user input text style...
0
 
LVL 21

Expert Comment

by:Tapan Pattanaik
ID: 39286198
Hi  asp_net2,

Use the text-transform property to convert your text to upper case, to lower case, or you can use it to capitalize words within your html text.

    text-transform: none;
    text-transform: uppercase;
    text-transform: lowercase;
    text-transform: capitalize;
    text-transform: inherit;

for more details:

http://www.codertools.com/css_help_guide/css_text-transform.aspx
0
 
LVL 58

Expert Comment

by:Gary
ID: 39286882
text-transform only gives the appearance, it doesn't change the underlying data
So in your code behind you need to manipulate the data to Uppercase or use javascript to capitalize it at the client side.
0
 
LVL 15

Accepted Solution

by:
Jagadishwor Dulal earned 500 total points
ID: 39287807
If you are working for display purpose only than use css:
text-transform:uppercase

Open in new window


If you need to convert it to upper there is function in asp.net toUpper(); Like:
TextBox1.Text.ToUpper()

Open in new window


If you get combination of number and letter you need to convert it to string first.
0
 
LVL 11

Expert Comment

by:SAMIR BHOGAYTA
ID: 39320454
Hi...
You can also use jQuery as follows:

<script src="Scripts/jquery-1.3.2.js" type="text/javascript">
</script>
 <script type="text/javascript">
$(document).ready(function()
{
$("#txt").keydown(function(e)
{
 if (e.keyCode >= 65 & e.keyCode <= 90)
{
val1 = $("#txt").val(); $("#txt").val(val1 + String.fromCharCode(e.keyCode)); return false;
 }
 });
 });
</script>

OR
You can use css as follows:
Use a css style on the text box. Your css should be something like this:

.uppercase { text-transform: uppercase; }

<asp:TextBox ID="TextBox1" runat="server" Text="" CssClass="uppercase"></asp:TextBox>

You can also use this

onkeyup="this.value=this.value.toUpperCase();"  - is working

but

.uppercase { text-transform: uppercase; } is more user friendly
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
As a result of several questions about how to use Bootstrap I thought it would be a good idea to write down the development aspect of creating a Bootstrapped website in as little time as possible. Part 1 of this article will only concentrate on g…
In this tutorial viewers will learn how to style a decorative dropcap for the first letter in a paragraph using CSS. In CSS, create a new paragraph class by typing "p.fancy": Then, to style only the first letter of the first sentence, include the ps…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now