Keyup Events inconsistency in TextBox

5 posts, 1 answers
  1. Alanm
    Alanm avatar
    18 posts
    Member since:
    Mar 2007

    Posted 05 Jul 2012 Link to this post

    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.
  2. Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 10 Jul 2012 Link to this post

    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Alanm
    Alanm avatar
    18 posts
    Member since:
    Mar 2007

    Posted 13 Jul 2012 Link to this post

    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>
  5. Answer
    Maria Ilieva
    Admin
    Maria Ilieva avatar
    4017 posts

    Posted 19 Jul 2012 Link to this post

    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.
  6. Roelof
    Roelof avatar
    1 posts
    Member since:
    May 2009

    Posted 26 Jul 2012 Link to this post

    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
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017