This must be my week for strange problems. Actually, I'm upgrading half a million lines of code from ASP.NET 2.0 to 4.0, and taking my telerik from 2009 Q3 to 2011 Q3, so I've got to catch up on 2 - 5 years of advancements.
Anyway, I'm seeing some strageness in RadInput. I'm trying to add a specific default button for the enter key. Simple enough, right? Handle the keypress and act on keyCode 13.
I've found through testing though, that when you have MaxLength defined on the field, characters don't seem to be accepted. The enter key still works fine, but nothing shows up in the field.
Here's what I did:
And yes, I know (now) that strings are immutable and I should be using a StringBuilder instead of += ... let's stick to the topic, eh? :)
Anyway, I can live without the MaxLength, I just wanted to share the pain and maybe help someone who can't figure out why their keyboard suddenly stopped working on that textbox.
-Chris
Anyway, I'm seeing some strageness in RadInput. I'm trying to add a specific default button for the enter key. Simple enough, right? Handle the keypress and act on keyCode 13.
I've found through testing though, that when you have MaxLength defined on the field, characters don't seem to be accepted. The enter key still works fine, but nothing shows up in the field.
Here's what I did:
s =
string
.Empty;
s +=
"function "
+
this
.ClientID +
"_defaultEnter(sender, eventArgs) { \r\n"
;
s +=
" var c = eventArgs.get_keyCode(); \r\n"
;
s +=
" var btn = document.getElementById('"
+ btnSearch.ClientID +
"'); \r\n"
;
s +=
" if (c == 13){ \r\n"
;
s +=
" btn.click(); \r\n"
;
s +=
" eventArgs.set_cancel(true); \r\n"
;
s +=
" } \r\n"
;
s +=
"}\r\n"
;
this
.Page.ClientScript.RegisterClientScriptBlock(
this
.GetType(),
this
.ClientID +
"_defaultEnter"
, s,
true
);
fldCaseNumber.ClientEvents.OnKeyPress =
this
.ClientID +
"_defaultEnter"
;
And yes, I know (now) that strings are immutable and I should be using a StringBuilder instead of += ... let's stick to the topic, eh? :)
Anyway, I can live without the MaxLength, I just wanted to share the pain and maybe help someone who can't figure out why their keyboard suddenly stopped working on that textbox.
-Chris