This is a migrated thread and some comments may be shown as answers.

Textbox value

5 Answers 97 Views
Input
This is a migrated thread and some comments may be shown as answers.
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
sitefinitysteve asked on 20 Sep 2010, 05:43 PM
I'm trying to do a dynamic search with the textbox...but it's really tanking with

  1. backspace, always a letter behind
  2. paste: so if I type 'ste' into the box, copy and paste it, the value is stev (ctrl-v for paste)

I need live text to be passed into the service

This is what I'm doing, but again, epic fail :)
$('#directorywidgetClientState').attr('value', sender.get_textBoxValue() + args.get_keyCharacter());

5 Answers, 1 is accepted

Sort by
0
Accepted
Dimo
Telerik team
answered on 21 Sep 2010, 11:33 AM
Hi Steve,

I suppose you are using the keypress/keydown events in your scenario, but as they do not work consistently in all browsers (due to browser inconsistencies), you will have problems with retrieving the correct textbox value.

That's why I suggest you to leave the key events alone and retrieve the textbox value constantly once the control receives focus. You will need the setTimeout and setInterval Javascript methods.

Best wishes,
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
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 21 Sep 2010, 02:01 PM
I'm sorry, how do you mean :)

...I need to know what's in that RadTextBox as I type into it.

So then handle OnFocus to start a timer, and stop the timer on ValueChanged?

KeyPress then I take it is to just prevent certain keys from being used eh
0
Accepted
Dimo
Telerik team
answered on 21 Sep 2010, 02:05 PM
Hi Steve,

>> "and stop the timer on ValueChanged"

I suppose OnBlur will be better in this case - ValueChanged is fired also when programmatic value change takes place and in this case you will have no timer to stop, because the control has no focus.

Regards,
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
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 21 Sep 2010, 02:06 PM
Thanks Dimo!
0
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
answered on 21 Sep 2010, 02:35 PM
Here's the code if someone else needs it...timer set at 1 second

//Global Vars
var directoryTimerID = 0;
var directorySearchBox = null;
 
//Start the timer when it gets focus
function onDirectorySearchFocus(sender, args) {
    directoryTimerID = setInterval("directorySearchTimer()", 1000);
    directorySearchBox = sender;
}
 
//Clear the timer when it loses Focus
function onDirectorySearchBlur(sender, args) {
    clearInterval(directoryTimerID);
    directorySearchBox = null;
}
 
//Timer callback function
function directorySearchTimer() {
    setDirectoryClientState(directorySearchBox.get_value());
}
Tags
Input
Asked by
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Answers by
Dimo
Telerik team
sitefinitysteve
Top achievements
Rank 2
Iron
Veteran
Share this question
or