How to attach client event to textbox inside RadSearchBox?

3 posts, 1 answers
  1. Robin
    Robin avatar
    41 posts
    Member since:
    Sep 2012

    Posted 30 Jul 2013 Link to this post

    Hi, 

    Is there a way to attach client event to textbox inside RadSearchBox control?
    I want to attach keypress event and check whether user press "Enter" key or not.

    Thanks in advanced,
    Robin


  2. Answer
    Plamen
    Admin
    Plamen avatar
    2734 posts

    Posted 02 Aug 2013 Link to this post

    Hello Robin,

     
    Thank you for contacting Telerik support.

    One way to achieve such behavior is by using jQuery as in the code below:

    <script type="text/javascript">
     
               function pageLoad() {
                   var $ = $telerik.$;
                   $(".rsbInput ").keypress(function (event) {
                       if (event.which == 13) {
                           alert("enter pressed");
                       }
                   });
               }
     
           </script>


    Hope this will be helpful. If you have further questions please don't hesitate to contact us again.

    Regards,
    Plamen
    Telerik
    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 the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Robin
    Robin avatar
    41 posts
    Member since:
    Sep 2012

    Posted 02 Aug 2013 Link to this post

    Thanks a lot, Plamen.
    My problem is that when I press "Enter" key inside RadSearchBox, other button click event is if firing
    and that's why I'm trying add event.preventDefault() for this textbox.
    Now, my problem solved by using your provided code sample.

    Thanks and best regards, 
    Robin
Back to Top