Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Web Text Control FORCE uppercase?
Message
General information
Forum:
ASP.NET
Category:
The Mere Mortals .NET Framework
Miscellaneous
Thread ID:
00833159
Message ID:
00833582
Views:
16
Stephen,

I didn't realize you needed this for the web. My mistake. To force uppercase for web textboxes, do the following:

1. add the following to your textbox in the HTML view:
onkeypress="CheckKey()"
2. Add the following javascript in the HTML view:
function CheckKey()
{
	key=event.keyCode;
	if (key >= 97  && key <= 122)
	{
		event.keyCode = key - 32;
	}
}
>Thanks Cathi, I'm having a hard time finding the WEB equivalent for:
>
> System.Windows.Forms.KeyEventArgs e)
>
>When I get to System.Web.UI.???
>
>System.Web.UI.HtmlControls.HtmlForm.ReferenceEquals e)
>
>Any pointers for this WEB version?
>
>Thanks.
>
>__Stephen
>
>
>>Hi Stephen,
>>
>>To force the text entered to be uppercase, you can use the following code for the KeyUp event:
>>
>>
>>private void mmtextBox1_KeyUp(object sender,
>>     System.Windows.Forms.KeyEventArgs e)
>>{
>>	this.mmtextBox1.Text = this.mmtextBox1.Text.ToUpper();
>>	mmtextBox1.SelectionStart = mmtextBox1.Text.Length;
>>	base.OnKeyUp(e);
>>}
>>
>>
>>
>>>I have a WEB MmTextBox that needs to FORCE uppercase in data being typed in.
>>>
>>>I am already doing :
>>>
>>>MmTextBox1.Text = dsGetDepapplCL.Tables["depappl"].Rows[0]["ap_part"].ToString().ToUpper() ;
>>>MmTextBox1.DataBind();
>>>
>>>in my save, but that's not good enough.
>>>
>>>Any ideas?
>>>
>>>TIA
>>>
>>>__Stephen
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform