Solved

Convert LowerCase to UpperCase in ASP.NET

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 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

19 Experts available now in Live!

Get 1:1 Help Now