Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

force uppercase characters in textbox as user types

Posted on 2011-02-24
8
Medium Priority
?
844 Views
Last Modified: 2012-08-13
How do I convert text to uppercase as the user types?  I have tried a few things, nothing worked how I need it.  While the user types, it searches through a database that is all uppercase so doing this in the code behind and then sending it is not going to work.

Any Ideas?
0
Comment
Question by:gfedz
[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
8 Comments
 
LVL 3

Expert Comment

by:4runnerfun
ID: 34971581
you can take the string you're searching with .tostring.toupper
0
 
LVL 17

Expert Comment

by:nepaluz
ID: 34971627
implement the toupper on the KeyUp event of the textbox
0
 
LVL 1

Author Comment

by:gfedz
ID: 34971635
<tr>
  <td colspan="2">
    <span style="font-weight:bold">Enter Last Name, First Name:</span>&nbsp;
    <asp:TextBox ID="txtFindName" runat="server" Width="250px" />&nbsp;
    <asp:AutoCompleteExtender ID="AutoCompleteExtender1" runat="server" 
	TargetControlID="txtFindName" ServiceMethod="FindNameSID" 
        MinimumPrefixLength="3" ServicePath="~/User/AutoComplete.asmx" />
    <asp:TextBoxWatermarkExtender ID="TextBoxWatermarkExtender1" 
	runat="server" TargetControlID="txtFindName" 
        WatermarkCssClass="WtrMrk" WatermarkText="SNUFFY JOE" />
    <asp:LinkButton ID="btnFindNameAdd" runat="server" Text="Add to Roster" ToolTip="Click to Add Member to Roster" />
  </td>
</tr>

Open in new window

<WebMethod()> _
    Public Function FindNameSID(ByVal prefixText As String, ByVal count As String) As String()
        Dim items As New List(Of String)

        sql = "SELECT name_ind FROM OPENQUERY(SIDPERS, 'Select name_ind from pers_person_tbl where name_ind like ''%" & prefixText & "%''')"

        myDataTable = New DataTable
        myDataTable = getData(sql)

        If myDataTable.Rows.Count > 0 Then
            For Each dRow As DataRow In myDataTable.Rows
                items.Add(dRow(0).ToString)
            Next
        End If
        Return items.ToArray

    End Function

Open in new window

0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 10

Accepted Solution

by:
P1ST0LPETE earned 2000 total points
ID: 34971705
No need to use VB code behind.  Just use javascript:
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script type="text/javascript">
        function UpperCase(textbox)
        {
            var text = textbox.value;
            textbox.value = text.toUpperCase();
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="text" id="textbox1" onkeyup="UpperCase(this)" />
    </div>
    </form>
</body>
</html>

Open in new window

0
 
LVL 1

Author Comment

by:gfedz
ID: 34972371
That does work.  There is a longer delay then normal for the response from the database, which is expect.  Is there any other methods that would work?
0
 
LVL 10

Expert Comment

by:P1ST0LPETE
ID: 34972538
Um, I'm sure there are several various ways you could dream up to achieve this.  However, this is the fastest and most correct way to do it.  Using JavaScript, allows the code to execute right there on the clients machine.  If you do a postback, even if you don't go to the database, you sill have to take the time to do a postback which is un-needed and typically MUCH slower than JavaScript, especially once the website is live and not in your local test environment.
0
 
LVL 1

Author Comment

by:gfedz
ID: 34972587
I do understand that.  Next question then, is there a quicker way of doing an autocomplete on a textbox then?  The ajax extender it self is already sluggish.
0
 
LVL 1

Author Closing Comment

by:gfedz
ID: 34997836
Works great, was hoping for a different method but this will have to do.
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

722 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