RadTextBox postback problem

2 posts, 0 answers
  1. Duy
    Duy  avatar
    68 posts
    Member since:
    Apr 2009

    Posted 28 Apr 2009 Link to this post

    Hi,

    I implemented with RadTextBox, when it runs, I pressed "enter", it causes a post back event and it runs through all defined events of other components.  I tried to set the attribute autopostback to be true unfortunately it does not help as the standard textbox of visual studio does.

    Cheers,

    Duy
  2. ManniAT
    ManniAT avatar
    877 posts
    Member since:
    Nov 2003

    Posted 28 Apr 2009 Link to this post

    Hi,

    with RadInput it is very simple to prevent such a thing - add a handler for KeyPress to it:
    <telerik:RadNumericTextBox runat="server" ID="neNumValues" ClientEvents-OnKeyPress="KeyPressed"></telerik:RadNumericTextBox> 
    And than handle this event in a simple script like this:
    <script language="JavaScript" type="text/javascript">  
    function KeyPressed(ctrl, e) {  
        if (e.get_domEvent().rawEvent.keyCode == 13) { //enter  
                //special handling (focus other control and so on) here  
                e.get_domEvent().preventDefault();  
                e.get_domEvent().stopPropagation();  
            }  
            if (e.get_domEvent().rawEvent.keyCode == 27) { // ESC  
                //special handling (clear values and so on) here  
                e.get_domEvent().preventDefault();  
                e.get_domEvent().stopPropagation();  
            }  
        }  
    </script>  
     

    If you do not handle Enter the event will "bubble up" - find a control (submit button or so) and this fires the postback.

    HTH

    Manfred
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top