TextBox WebControl

P

pramod

Hi,

I want to know if this is possible.

Can TextBox webcontrol be set in a way all the charaters entered by user are
uppercase.

Is this possible? if yes how?

thanks in advance.
-P
 
J

Jim Cheshire [MSFT]

Hi Pramod,

You can do this in many ways. If you want to depend on the user to do this
and just notify them when they haven't, the RegularExpressionValidator
control is a perfect solution. If you want to allow the user to enter
lower-case characters and then convert them to upper-case yourself, that's
easy as well.

Depending on the language you are using and whether you need the text
upper-case when it's on the client or on the server, the options will be
different. Can you be more specific? If you can also tell us what
language you're using, we can provide possible samples in the language you
are used to.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.


--------------------
 
P

pramod

Jim Thanks for your response.

But this is what I am looking for.

When user start typing in TextBox control, irrespective to caps lock on or
off character typed should be uppercase.

As of now I let user type in any case and then convert them to uppercase.

I am using C# language.

thanks,
-P

Jim Cheshire said:
Hi Pramod,

You can do this in many ways. If you want to depend on the user to do this
and just notify them when they haven't, the RegularExpressionValidator
control is a perfect solution. If you want to allow the user to enter
lower-case characters and then convert them to upper-case yourself, that's
easy as well.

Depending on the language you are using and whether you need the text
upper-case when it's on the client or on the server, the options will be
different. Can you be more specific? If you can also tell us what
language you're using, we can provide possible samples in the language you
are used to.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.


--------------------
From: "pramod" <[email protected]>
Subject: TextBox WebControl
Date: Mon, 9 Feb 2004 10:26:49 -0500
Lines: 13
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: out3.datatelecomm.net 167.23.240.20
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13.
phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:18152
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

Hi,

I want to know if this is possible.

Can TextBox webcontrol be set in a way all the charaters entered by user are
uppercase.

Is this possible? if yes how?

thanks in advance.
-P
 
R

Rafa®

You can write a CSS class and assign it to the TextBox
It will look like something like that

<style> .uppertext { text-transform: uppercase; } </style><asp:TextBox ID="myTextBox" CssClass="uppertext" Runat="Server" /

This way, it preserves what the user types when you parse it back to the server..
So, if you need to use store this upper-case, you still need to upper it in your code

string Result
Result = myTextBox.ToUpper()

Still, you load some value into the textbox, it automatically Uppercase it..
This property of stylesheet still provides a Capitalization option, it's interesting because you don't need to implement any aditional client script/code.
 
J

Jim Cheshire [MSFT]

Pramod,

In that case, you will need to use client-side script. This is not going
to be possible with ASP.NET because HTTP is a disconnected architecture.

Here is a simple sample of JavaScript that will do what you want to do:

<input id="myInputBox" type="text" onkeyup="this.value =
this.value.toUpperCase();">

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
Subject: Re: TextBox WebControl
Date: Mon, 9 Feb 2004 11:35:37 -0500
Lines: 77
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: out3.datatelecomm.net 167.23.240.20
Path: cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
.phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:18160
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

Jim Thanks for your response.

But this is what I am looking for.

When user start typing in TextBox control, irrespective to caps lock on or
off character typed should be uppercase.

As of now I let user type in any case and then convert them to uppercase.

I am using C# language.

thanks,
-P

Jim Cheshire said:
Hi Pramod,

You can do this in many ways. If you want to depend on the user to do this
and just notify them when they haven't, the RegularExpressionValidator
control is a perfect solution. If you want to allow the user to enter
lower-case characters and then convert them to upper-case yourself, that's
easy as well.

Depending on the language you are using and whether you need the text
upper-case when it's on the client or on the server, the options will be
different. Can you be more specific? If you can also tell us what
language you're using, we can provide possible samples in the language you
are used to.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.


--------------------
From: "pramod" <[email protected]>
Subject: TextBox WebControl
Date: Mon, 9 Feb 2004 10:26:49 -0500
Lines: 13
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: out3.datatelecomm.net 167.23.240.20
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
 
P

pramod

Thanks Jim..

Jim Cheshire said:
Pramod,

In that case, you will need to use client-side script. This is not going
to be possible with ASP.NET because HTTP is a disconnected architecture.

Here is a simple sample of JavaScript that will do what you want to do:

<input id="myInputBox" type="text" onkeyup="this.value =
this.value.toUpperCase();">

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.

--------------------
Subject: Re: TextBox WebControl
Date: Mon, 9 Feb 2004 11:35:37 -0500
Lines: 77
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <#[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: out3.datatelecomm.net 167.23.240.20
Path:
cpmsftngxa07.phx.gbl!cpmsftngxa10.phx.gbl!TK2MSFTNGXA05.phx.gbl!TK2MSFTNGP08
phx.gbl!TK2MSFTNGP11.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.framework.aspnet.webcontrols:18160
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webcontrols

Jim Thanks for your response.

But this is what I am looking for.

When user start typing in TextBox control, irrespective to caps lock on or
off character typed should be uppercase.

As of now I let user type in any case and then convert them to uppercase.

I am using C# language.

thanks,
-P

Jim Cheshire said:
Hi Pramod,

You can do this in many ways. If you want to depend on the user to do this
and just notify them when they haven't, the RegularExpressionValidator
control is a perfect solution. If you want to allow the user to enter
lower-case characters and then convert them to upper-case yourself, that's
easy as well.

Depending on the language you are using and whether you need the text
upper-case when it's on the client or on the server, the options will be
different. Can you be more specific? If you can also tell us what
language you're using, we can provide possible samples in the language you
are used to.

Jim Cheshire, MCSE, MCSD [MSFT]
ASP.NET
Developer Support
(e-mail address removed)

This post is provided as-is with no warranties and confers no rights.


--------------------
From: "pramod" <[email protected]>
Subject: TextBox WebControl
Date: Mon, 9 Feb 2004 10:26:49 -0500
Lines: 13
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webcontrols
NNTP-Posting-Host: out3.datatelecomm.net 167.23.240.20
Path:

cpmsftngxa07.phx.gbl!cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!tk2msftngp13
 
P

pramod

Thanks Rafa
Rafa® said:
You can write a CSS class and assign it to the TextBox.
It will look like something like that:

<style> .uppertext { text-transform: uppercase; } </style><asp:TextBox
ID="myTextBox" CssClass="uppertext" Runat="Server" />
This way, it preserves what the user types when you parse it back to the server...
So, if you need to use store this upper-case, you still need to upper it in your code:

string Result;
Result = myTextBox.ToUpper();

Still, you load some value into the textbox, it automatically Uppercase it...
This property of stylesheet still provides a Capitalization option, it's
interesting because you don't need to implement any aditional client
script/code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,099
Messages
2,570,626
Members
47,237
Latest member
David123

Latest Threads

Top