Link to home
Start Free TrialLog in
Avatar of htabbach
htabbachFlag for United States of America

asked on

How to capitalize the content of a an ASP textbox without posting

Hello,

I have a web application where call center reps enter information about the caller. They want the app to capitalize the first and last name after entering them. I made the text box post back and in the textChanged event I called this function:

txtFName.Text = StrConv(txtFName.Text, VbStrConv.ProperCase)

Works great. The problem is that users did not like the fact that the page posts everytime they exit the control. Is there a way to do the same on the client side without posting?
Avatar of Dxpert
Dxpert
Flag of United States of America image

I think that the easier way out here, would be to use, CSS:  text-transform: capitalize;
Not sure it will work on all browsers. But It works on FireFox and IE 7

You can test it adding this to an html file.
<input type="text" name="txt" size="35" style="text-transform: capitalize;">
Avatar of htabbach

ASKER

That would work but when I replaced my ASP textbox with an Input textbox and I declared the control in my VB.NET it fails and tells me that object is not set.
<asp:TextBox ID=txtId runat=server Text=ID style=text-transform: capitalize; Width=40px></asp:TextBox>

You can do it with Asp:textbox - it will render as input type="text" ;-)
ASKER CERTIFIED SOLUTION
Avatar of Dxpert
Dxpert
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks! Glad I could help.