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

[Solved] Stop events queue in OnKeyPress

2 Answers 192 Views
Input
This is a migrated thread and some comments may be shown as answers.
Grisha
Top achievements
Rank 1
Grisha asked on 19 Nov 2007, 08:44 PM
I need to stay on the form when user enters something in the TextBox and preses Enter without doing postback with default button (either from Form or asp:panel).

I tried the usual JS approach to return false at the end of OnKeyPress but no luck.
Is there way to do this?

Thanks,
Grisha

2 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 20 Nov 2007, 08:32 AM
Hello Grisha,

As you are using the ASP.NET AJAX-based version of the control you can cancel the event using the ASP.NET AJAX convention for canceling client events:

<form id="form1" runat="server" defaultbutton="Button1"
    <asp:ScriptManager ID="ScriptManager1" runat="server"
    </asp:ScriptManager> 
    <div> 
 
        <script type="text/javascript"
        function OnKeyPress(sender, args) 
        { 
            if (args.get_KeyCode() == 13) 
            { 
                args.set_cancel(true); 
            } 
        } 
        </script> 
 
        <telerik:RadTextBox ID="RadTextBox1" runat="server"
            <ClientEvents OnKeyPress="OnKeyPress" /> 
        </telerik:RadTextBox> 
         
        <asp:Button ID="Button1" runat="server" Text="Button" /> 
 
    </div> 
</form> 



Best wishes,
Manuel
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Grisha
Top achievements
Rank 1
answered on 20 Nov 2007, 02:17 PM
Thanks,

Works fine!
Tags
Input
Asked by
Grisha
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
Grisha
Top achievements
Rank 1
Share this question
or