Solved

Convert text to Uppercase in CSS using ASP.NET

Posted on 2013-06-28
5
601 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ASP.NET Calendar Control 5 31
Silly CSS question - cant figure out 2 24
How can I make my tabs look like this? 1 35
Change color in a check box 8 18
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In this Micro Tutorial viewers will learn how to create navigation buttons that change on rollover, using CSS (Continuation of the CSS Image Sprite tutorial) Create a parent ID for all the list items       - Specify position: absolute and display: block…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

697 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