problem with input from textbox

easyeman

Active member
Joined
Nov 16, 2005
Messages
28
Location
Decatur, AL
Programming Experience
1-3
I need some help...I have a page that allows a customer to type in a customer number and Purchase Order number, and I have it set to Autopostback for the CustNum so that when a customer types their 6 digit Customer Number in, it will pull up their billing information on that page and then they can click the next button to continue checking out with selecting shipping address, etc like a Web site normally has.

The problem I found is that it is case-sensitive so if a customer types in say "dec050" then it will pull up the Billing Information as "NONE" even though that is a good number. But when you type in "DEC050" with caps it will display it correctly.

However, the annoying thing that is happening is that I have set a CSS tag to cause the text to automatically capitalize (text-transform: uppercase) which seems easy enough. But for some odd reason that doesn't work, and while it makes the text all caps when typing in the textbox, it still doesn't pull up the billing information! Basically I can type in "dec050" with no caps and it will display "DEC050" but it won't pull it...HOWEVER when I actually have caps-lock on or hold shift to enter "DEC050" it works! It's killing me

This is just getting annoying for me, so does anyone have any suggestions as to how to fix this. I'm just trying to get the billing information to pull up in the area at the bottom when a customer enters a good Customer Number, and I want it set so that the customer can just type it in and it not be case-sensitive. Is there a way to fix it on input or is there some code I need to put in so it does it in the VB code? It seems simple but I'm lost and need help. I appreciate it!
 
Look into the ToUpper method of the System.String class.

The reason using css styling to display the text in uppercase doesn't work is because the css is only affecting the way the text is being displayed and not the actual text value.
 
Look into the ToUpper method of the System.String class.

The reason using css styling to display the text in uppercase is because the css is only affecting the way the text is being displayed and not the actual text value.


Hey thanks! finally someone who is willing to help haha. Yeah I was figuring that, it was just showing the text but not affecting the value. I guess the reason I was trying it that way is because I did the Upper method first in VB but got no results. Would I need to combine both or just use the ToUpper method for it to work?

Just in case, here is the code I have in VB that is doing the pulling and such, so you can see what I have and what I'd need to do. Thanks and I'll mess around with the ToUpper method to see if I can get it to work.

VB.NET:
Dim strNevisID As String

strNevisID = txtCustNum.Text.Trim '(txtCustNum is of course the name of the textbox I have where customers insert the Customer number)

        If strNevisID.Length > 5 Then
            'Gets the current Billing Address from ISeries Database
            Dim Info As site.WebStore.MyAccountDB = New site.WebStore.MyAccountDB
            Dim BA As site.WebStore.BillingInfo = New site.WebStore.BillingInfo

            BA = Info.GetBillingAddress(strNevisID)
            BName.Text = BA.Name
            BA1.Text = BA.Address1
            If Trim(BA.Address2).Length > 2 Then
                BA2.Visible = True
                BA2.Text = BA.Address2
            End If
            If Trim(BA.Address3).Length > 2 Then
                BA3.Visible = True
                BA3.Text = BA.Address3
            End If
            BCity.Text = BA.City
            BState.Text = BA.State
            BZip.Text = BA.Zip
        End If
 
The code for the Info.GetBillingAddress method would be helpful to see how you are querying the database.

Alright sounds good, whatever can help solve this =) I just didn't wanna post too much code that may be unnecessary. Here is the code for the GetBillingAddress method within the MyAccountDB in the database.

VB.NET:
'*******************************************************
        ' The GetBillingAddress method returns a BillingInfo
        ' struct that contains information about a specific
        ' customer's billing address
        '*******************************************************

        Public Function GetBillingAddress(ByVal CustID As String) As BillingInfo
            ' Create Instance of Connection and Command Object
            Dim con As iDB2Connection = Misc.GetConnection()
            Dim myCommand As iDB2Command = New iDB2Command("SELECT CMNAME,CMADD1,CMADD2,CMADD3,CMCITY,CMSTA,CMZIP From NATFILES.OECMF01 WHERE CMCUST ='" & CustID & "'", con)
            Dim myReader As iDB2DataReader

            ' Create CustomerDetails Struct
            Dim myBillingInfo As BillingInfo = New BillingInfo

            con.Open()
            myReader = myCommand.ExecuteReader(CommandBehavior.SingleRow Or CommandBehavior.CloseConnection)

            Try
                If myReader.HasRows Then
                    While myReader.Read()
                        myBillingInfo.Name = CStr(myReader.Item("CMNAME"))
                        myBillingInfo.Address1 = CStr(myReader.Item("CMADD1"))
                        myBillingInfo.Address2 = CStr(myReader.Item("CMADD2"))
                        myBillingInfo.Address3 = CStr(myReader.Item("CMADD3"))
                        myBillingInfo.City = CStr(myReader.Item("CMCITY"))
                        myBillingInfo.State = CStr(myReader.Item("CMSTA"))
                        myBillingInfo.Zip = CStr(myReader.Item("CMZIP"))
                    End While
                Else
                    myBillingInfo.Name = "NONE"
                End If

                If Trim(myBillingInfo.Zip).Length > 5 Then
                    myBillingInfo.Zip = Left(myBillingInfo.Zip, 5) & "-" & Right(myBillingInfo.Zip, 4)
                End If

                Return myBillingInfo

            Catch ex As Exception
                Return Nothing
            Finally
                myReader.Close()
                con.Close()
            End Try
        End Function
 
argh nevermind...I realized I just had to put the ToUpper method with the statement I already have.

strNevisID = txtCustNum.Text.ToUpper.trim

I think that's what I gotta do, but I was trying to do it as two statements. Figured it was something simple I was overlooking. Thanks for the help though!
 
So did it work using the ToUpper method?

Yes it did, thanks! haha yeah I just tested it out and it works great. I don't know why I didn't see that before, but I was doing was having two statements to do it instead of one. I wasn't thinking about just having the ToUpper and Trim methods together, but once I did that it worked great. Now I may just put in the CSS style too so the text appears in all caps, though it doesn't matter now since the data will read as all caps. It pulls no matter what now which is great. I appreciate the help though. I guess sometimes when I just talk about it or go away and come back to it the solution hits me and I can't believe it took me that long to do =)

anyway, I do have one more thing I'm trying to do which shouldn't be hard either. I'm wanting to verify that the text entered in the CustNum is valid in terms of it being in the system. What I was going to do was set an If Statement testing if the Billing Name was equal to "NONE" and if so throw an error and have them have to do it again. That should work for testing since anytime a wrong number is entered the Billing Name shows "NONE" and it would only do that if the number was invalid.

What would you suggest be the best way to set that up? But otherwise once that is done I'll have the page completed. I was just stuck on those two minor things but the rest of the code works great.
 
In your first code block posted, after BA = Info.GetBillingAddress(strNevisID), check to see if BA.Name = "NONE". If it does display a message to the user that the customer number wasn't found.
 
In your first code block posted, after BA = Info.GetBillingAddress(strNevisID), check to see if BA.Name = "NONE". If it does display a message to the user that the customer number wasn't found.

Alright sweet, that's actually what I did so I figured I had it right. I just put it in a different spot which may be why it didn't work quite as I expected. The only thing I had to adjust was adding an Else statement to clear the Error textbox since even when someone inserts a correct CustNum, the error still wants to show up and doesn't go away but it pulls in the billing information. For some reason it doesn't want to show up in my testing though, although I'm sure that'll work.

Also, would you suggest I use the same line of code for the ClickButton? I guess I didn't mention that earlier, but I also have it where the user clicks the button to submit info to go to the next page, and obviously if there's no code there to test the CustNum it'll just go through anyway without an error. I guess I just want to make sure it throws an error but stops the user from proceeding with the incorrect number. Anything I should change for that or would the same code work? I appreciate the help.
 
Also, would you suggest I use the same line of code for the ClickButton? I guess I didn't mention that earlier, but I also have it where the user clicks the button to submit info to go to the next page, and obviously if there's no code there to test the CustNum it'll just go through anyway without an error. I guess I just want to make sure it throws an error but stops the user from proceeding with the incorrect number. Anything I should change for that or would the same code work? I appreciate the help.
If you have two events using the same code, create a procedure and call that procedure from both event handlers (your example could be called GetBillingAddress, a different method than Info.GetBillingAddress). This is a good object oriented approach, reuse and reduce code.
 
Back
Top