Solved

Convert text to Uppercase in CSS using ASP.NET

Posted on 2013-06-28
5
596 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 10

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
This article describes how to create custom column layout styles for Bootstrap. The article uses 5 columns to illustrate the concept, but the principle can be extended to any number of columns.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…

789 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