Link to home
Start Free TrialLog in
Avatar of Pete2003
Pete2003

asked on

Typing in uppercase in a TextBox

Hi All,

I remember that in C++ (MFC) you could specify whether the text box is a password and if you want to use uppercase/lowercase or as typed.

I see now you can still specify the password part but there is no way of changing what is being typed to uppercase ...

Is this true or am I missing something ... if not is the only way of fixing this by using an onchange event ?

Txs
Peter
Avatar of AlexFM
AlexFM

Avatar of Pete2003

ASKER

Sorry wasn't specific enough .. I meant for WEB forms .. not windows forms ...

Txs
Peter
You cannot change this for Web forms. This is not part of .Net or C# but from the HTML standards and you cannot change it :-(( You can however write some JavaScript that changes the text to upper when the user enters something in your text box
ASKER CERTIFIED SOLUTION
Avatar of Timbo87
Timbo87

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
Avatar of David H.H.Lee
Pete2003,
Try this instead (use some delay to convert the typed text into uppercase):
function convertUpperCase(keyItem)  {
     setTimeout('ConvertKey("' +keyItem+ '")', 1);
}
function ConvertKey(selObj)  {
     document.getElementById(selObj).value = document.getElementById(selObj).value.toUpperCase();
}
</script>
<asp:textbox id="txtTest" runat="server"/>

txtTest.Attributes.Add("onKeyPress","convertUpperCase('txtTest')")'code-behind