Solved

Convert LowerCase to UpperCase in ASP.NET

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
This is a video describing the growing solar energy use in Utah. This is a topic that greatly interests me and so I decided to produce a video about it.

919 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

16 Experts available now in Live!

Get 1:1 Help Now