Solved

Convert LowerCase to UpperCase in ASP.NET

Posted on 2006-07-06
4
336 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …

730 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