I have a radtextbox in my screen. When user enters the characters by default it should display in capital letter.
I have written like this, but it is not working
<
telerik:RadTextBox ID="radtxtCarrierComments" MaxLength="50" Width="350px" runat="server" onkeypress="return AllowAlphaNumericandSpace(event);" onkeydown="javascript:EnableOk();" AutoPostBack="true" style="text-transform: uppercase;">
</telerik:RadTextBox>
In this I have both onkeypress and onkeydown client events + i have set the style property.
Can anybody help me in this?
5 Answers, 1 is accepted

Hello Medac,
I found its working for me after I added the style that you tried. I even tried with different browsers (IE8, Firefox, Opera) and the found the typed letter in uppercase only. Is it happening for any specific browser, in your case?
I tried another workaround for setting the typed text to uppercase by attaching the 'OnKeyPress' event to RadTextBox. Here is the code that I tried.
ASPX:
<telerik:RadTextBox ID="radtxtCarrierComments" MaxLength="50" Width="350px" runat="server" |
AutoPostBack="true" OnTextChanged="radtxtCarrierComments_TextChanged" Style="text-transform: uppercase;"> |
<ClientEvents OnKeyPress="OnKeyPress" /> |
</telerik:RadTextBox> |
JavaScript:
<script type="text/javascript"> |
var textBox; |
var text = new String(); |
function OnKeyPress(sender, args) { |
textBox = sender; |
text = args.get_keyCharacter(); |
text = sender.get_textBoxValue() + text.toUpperCase(); |
setTimeout("textBox.set_value(text);", 100); |
} |
</script> |
I hope the suggestion helps,
Shinu.


It is not clear whether you want the textbox value to only appear uppercase or to actually be uppercase. Check out the following example, which demonstrates both. The text-transform CSS style is used to make the textbox value appear uppercase, while the ValueChanging event is used to actually transform the value. No need to use keystroke events for that.
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<
script
runat
=
"server"
>
protected void radtxtCarrierComments_TextChanged(object sender, EventArgs e)
{
Label1.Text = (sender as RadTextBox).Text;
}
</
script
>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<
html
xmlns
=
"http://www.w3.org/1999/xhtml"
>
<
head
runat
=
"server"
>
<
meta
http-equiv
=
"content-type"
content
=
"text/html;charset=utf-8"
/>
<
title
>RadControls</
title
>
<
style
type
=
"text/css"
>
.upper
{
text-transform:uppercase;
}
</
style
>
</
head
>
<
body
>
<
form
id
=
"form1"
runat
=
"server"
>
<
asp:ScriptManager
ID
=
"ScriptManager1"
runat
=
"server"
/>
<
telerik:RadTextBox
ID
=
"radtxtCarrierComments"
runat
=
"server"
CssClass
=
"upper"
AutoPostBack
=
"true"
OnTextChanged
=
"radtxtCarrierComments_TextChanged"
>
<
ClientEvents
OnValueChanging
=
"MyValueChanging"
/>
</
telerik:RadTextBox
>
<
script
type
=
"text/javascript"
>
function MyValueChanging(sender, args)
{
args.set_newValue(args.get_newValue().toUpperCase());
}
</
script
>
<
br
/><
br
/>
textbox value: <
asp:Label
ID
=
"Label1"
runat
=
"server"
/>
</
form
>
</
body
>
</
html
>
All the best,
Dimo
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
