Solved

Convert text to Uppercase in CSS using ASP.NET

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
spacing 5 26
responsive divs setup - what am I doing wrong 2 30
Re-position sub-options beneath the TAB 7 37
CSS measurement 10 11
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this Micro Tutorial users will learn how to embed custom fonts into websites using @font-face in CSS Select a font: Ensure the EULA allows you to use @font-face: Download the font: Get the browser-compatible files you need: Edit your CSS       - Name …
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…

707 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

13 Experts available now in Live!

Get 1:1 Help Now