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

Keyup Events inconsistency in TextBox

4 Answers 187 Views
Input
This is a migrated thread and some comments may be shown as answers.
Alanm
Top achievements
Rank 2
Alanm asked on 05 Jul 2012, 10:23 AM
I've just upgraded to Q2 2012 and I'm now having a problem with code that has worked for months without any issues.  I've got an onkeyup function on a RadTextBox, which then fires an ajax request to get search results as the user types.  In Q2 2012 the value of the text box is not being consistently set before my onkeyup function is run.  So if I put a break point in the function I get

>>> $find("ctl00_MainContent_SearchBox").get_value()
""
>>> $find("ctl00_MainContent_SearchBox").get_textBoxValue()
"d"

In code behind when I do SearchBox.Text I get the blank value, not the text.  As soon as my onkeyup event has finnished the value is set correctly.  I did not have this issue in Q3 2011.

If I change the RadTextBox to an asp:TextBox the issue goes away.

4 Answers, 1 is accepted

Sort by
0
Maria Ilieva
Telerik team
answered on 10 Jul 2012, 09:07 AM
Hello Alan,
 
Could you please share your markup and the related code behind so we could replicate your scenario on our end? Thus we will be able to further research ion the problem and do our best to isolate its root cause.

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Alanm
Top achievements
Rank 2
answered on 13 Jul 2012, 09:16 AM
No problem.  The following snippet shows the problem.

Text1: a standard asp textbox works fine and popuplates p1 as you type.
Text2: a radtextbox with keyup event doesn't work.  The value only updates when you click outside the text box.  So you have to type, then click outside the textbox, then change the text again to get it to update.
Text2: a radtextbox with the client-onkeypress event instead.  Same problem.

In the production code that's now not working, I'm accessing the value from code behind (Text2.Text) after an ajax call made in the Javascript functions, but the code-behind Text2.Text value matches the result of get_value() so this demo proves the point.

Thanks,

<script language="javascript">
 
    function k1() {
        $("#p1").html($("#ctl00_MainContent_Text1").val());
    }
 
    function k2() {
        $("#p2").html($find("ctl00_MainContent_Text2").get_value());
    }
 
    function k3() {
        $("#p3").html($find("ctl00_MainContent_Text3").get_value());
    }
 
</script>
 
<p id="p1"></p>
<p id="p2"></p>
<p id="p3"></p>
 
<asp:TextBox runat="server" ID="Text1" onkeyup="k1();"></asp:TextBox>
<telerik:RadTextBox runat="server" ID="Text2" Text="" onkeyup="k2();"></telerik:RadTextBox>
<telerik:RadTextBox runat="server" ID="Text3" Text="" ClientEvents-OnKeyPress="k3"></telerik:RadTextBox>
0
Accepted
Maria Ilieva
Telerik team
answered on 19 Jul 2012, 01:24 PM
Hi Alan,

With the new version of the controls the asp TextBox control has value on the server only after blurring from the input or press and Enter. This change is done in order to made the TextBox compatible with the other input controls in our suit and have all of them share the same behaviour.
So in your case it is expected to not been able to access the value onkeyup event. Possible workaround in your case is to manually set the value to the textBoxValue like this
textbox.set_value(textbox.get_textBoxValue);

You could review the blog post below which list most important changes in the RadInput controls developed in the latest release:
http://blogs.telerik.com/aspnet-ajax/posts/12-06-22/changes-in-radinput-in-q2-2012-version-of-radcontrols.aspx

I hope this helps.

Regards,
Maria Ilieva
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
0
Roelof
Top achievements
Rank 1
answered on 26 Jul 2012, 02:24 PM
Maria,

Your description of the problem was accurate, but the solution did not work for me using 2012 Q2 (2012.2.607.35).

The value being edited is contained in the input element and I therefore used the following:

textbox.set_value(textbox.get_element().value);

Regards
Tags
Input
Asked by
Alanm
Top achievements
Rank 2
Answers by
Maria Ilieva
Telerik team
Alanm
Top achievements
Rank 2
Roelof
Top achievements
Rank 1
Share this question
or