Solved

Convert LowerCase to UpperCase in ASP.NET

Posted on 2006-07-06
4
346 Views
Last Modified: 2008-02-07
while typing into text box i want all the characters to come into Upper Case instead of lower case in ASP.NET.

Kindly advise some solution.

Rgds,
Sohrab
0
Comment
Question by:sohrabus
[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
  • 2
4 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 17056326
Hello sohrabus,

you have two ways to do this:

on client side using JavaScript function attached to onblur or to onkeypress events of the field or onsubmit event of the form.

function toupper()  { your_form_id.field_name.value = your_form_id.field_name.value.toUpperCase(); }

on server side after submitting:

field_id.Text = field_id.Text.ToUpper();    // C#


HTH

I
0
 
LVL 8

Expert Comment

by:kaliyugkaarjun
ID: 17056502
HI

If U need to change char to Uppercase at the time of keypress so u have to use Keypress event
and not on blur event as it will fire after the focus on textbox is lost.

For that u have add event to the textbox

 textbox1.Attributes.Add("onkeypress", "ToUpperCase('" & Me.textbox1.ClientID.ToString & "');")

And register the javascript Function on page load event in the following way

           Dim popupScripToUpper As String

          'javasript function for converting to upper case
           popupScripToUpper = "<script language='javascript'>" & _
            "function ToUpperCase(strFldName){" & _
            "var Item;" & _
            "Item = document.all(strFldName);" & _
            "Item.value = Item.value.toUpperCase(); " & _
            "}</script>"
            Page.RegisterStartupScript("popupScripToUpper ", popupScripToUpper )

Cheers!!!
0
 
LVL 7

Accepted Solution

by:
pradeepsudharsan earned 50 total points
ID: 17056506
hi,
We can use CSS to achieve this.
 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        TextBox1.Style.Add("text-transform", "uppercase")
End Sub

Regards
Pradeep
0
 
LVL 7

Expert Comment

by:pradeepsudharsan
ID: 17056531
hi,

1)Server Side:
-----------------------
 Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'Put user code to initialize the page here
        TextBox1.Style.Add("text-transform", "uppercase")
End Sub

2)Using java script
-------------------------------
                     <script language="javascript">
            function SetProperty()
            {
               document.getElementById('TextBox1').style.textTransform='uppercase';
            }
            </script>
      </HEAD>
      <body MS_POSITIONING="GridLayout" onload="SetProperty();">
            <form id="Form1" method="post" runat="server">
                                        -----

Regards
Pradeep
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

724 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