I have several Rad Textboxes with client side scripts attached to ClientEvent OnBlur. This script does two things checks to see that the box has text and changed the case of the text to Proper Case.
My mark-up for the Textbox is....
My hideError function is
The pCase function just goes through the text and capitalises only certain characters. This functions correctly and once a textbox has lost focus either a lable is populated with Mandatory Field if the box is empty or the text is properly capitalised if it contains any text.
My problem is on the server-side if I try to use the value of RadTextBox1.Text I get the text as it was originally typed not the capitalised version that is displayed. What am I doing wrong?
My mark-up for the Textbox is....
<
telerik:RadTextBox
ID
=
"RadTextBox1"
runat
=
"server"
EmptyMessage
=
"Please Enter"
SelectionOnFocus
=
"SelectAll"
Width
=
"100%"
>
<
ClientEvents
OnBlur
=
"function(sender,args){checkCap(sender, args, 'lb_RadTextBox1');}"
/>
</
telerik:RadTextBox
>
<
asp:Label
ID
=
"lb_RadTextBox1"
runat
=
"server"
CssClass
=
"error"
></
asp:Label
>
My hideError function is
function
checkCap(sender, args, label) {
var
tb = $(
'#'
+ sender._clientID);
var
lb = document.getElementById(label);
if
($.trim(tb[0].value) ==
""
) {
lb.innerHTML =
" Mandatory Field"
;
}
else
{
var
pc = pCase($.trim(tb[0].value));
tb[0].value = pc;
lb.innerHTML = "";
}
}
The pCase function just goes through the text and capitalises only certain characters. This functions correctly and once a textbox has lost focus either a lable is populated with Mandatory Field if the box is empty or the text is properly capitalised if it contains any text.
My problem is on the server-side if I try to use the value of RadTextBox1.Text I get the text as it was originally typed not the capitalised version that is displayed. What am I doing wrong?