Hi,

What is the code to write in txtCaps text box event which can change the whole text entered in as capital letters? Thanks.

Dani AI

Generated

asked for a way to force uppercase; pointed to a control property that works in Windows Forms. That property does not exist on the ASP.NET WebForms TextBox, so the exact code shown in the replies only applies to WinForms (see the Windows Forms docs for CharacterCasing for reference). For ASP.NET there are three practical approaches: server-side normalization, client-side transformation for immediate UX, and CSS for visual-only styling.

Server-side (VB.NET): canonicalize the value on postback so stored data is consistent. Convert the posted string to uppercase in the Button click handler or in the TextChanged handler (if using AutoPostBack) with a culture-safe method such as ToUpperInvariant() before saving or processing.

Client-side (better UX): transform input as the user types using JavaScript (for example, via the oninput event). A simple inline handler will make characters uppercase immediately. If you need to preserve caret position while transforming, capture and restore selectionStart/selectionEnd.

CSS (visual only): text-transform: uppercase; makes the input look uppercase in the browser but does not change the actual value sent to the server. Use this only for presentation or combine it with server-side normalization.

Recommendation: use client-side transformation for responsiveness, but always perform server-side normalization before saving or comparing values to avoid culture-related surprises (Turkish dotted/dotless i) — prefer ToUpperInvariant() for storage. Relevant docs: ASP.NET/WinForms property info and the CSS text-transform reference.

Recommended Answers

All 2 Replies

Hi,

What is the code to write in txtCaps text box event which can change the whole text entered in as capital letters? Thanks.

Hi,

You need the CharacterCasing property to do so.
Here's an example:

TextBox1.CharacterCasing = CharacterCasing.Upper

Hi,

You need the CharacterCasing property to do so.
Here's an example:

TextBox1.CharacterCasing = CharacterCasing.Upper

Thanks for you kind help.

Regards.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.