force uppercase characters in textbox as user types

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?
Who is Participating?
P1ST0LPETEConnect With a Mentor Commented:
No need to use VB code behind.  Just use javascript:
<html xmlns="">
<head runat="server">
    <script type="text/javascript">
        function UpperCase(textbox)
            var text = textbox.value;
            textbox.value = text.toUpperCase();
    <form id="form1" runat="server">
        <input type="text" id="textbox1" onkeyup="UpperCase(this)" />

Open in new window

you can take the string you're searching with .tostring.toupper
implement the toupper on the KeyUp event of the textbox
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

gfedzAuthor Commented:
  <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" />

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
        End If
        Return items.ToArray

    End Function

Open in new window

gfedzAuthor Commented:
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?
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.
gfedzAuthor Commented:
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.
gfedzAuthor Commented:
Works great, was hoping for a different method but this will have to do.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.