Solved

Convert LowerCase to UpperCase in ASP.NET

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

831 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