[CLOSED] Enter = submit

  1. #1

    [CLOSED] Enter = submit

    Is there any way make the default action of the enter key to submit? I'm using the keypress listener of the controls on my page and calling the click event of a button in the function called by the listener to do this, but i'm trying to find an easier way, since the default of the enter key is to submit.
    Last edited by Daniil; Dec 27, 2010 at 8:51 AM. Reason: [CLOSED]
  2. #2
    <ext:KeyMap ID="KeyMap1" runat="server" Target="Ext.getBody()">     
                <ext:KeyBinding StopEvent="true">         
                <Keys>             
                    <ext:Key Code="ENTER"/>          
                 </Keys>         
                 <Listeners>             
                    <Event Handler=" #{btnLogin}.fireEvent('click');" />      
                 </Listeners>    
                 </ext:KeyBinding> 
             </ext:KeyMap>
  3. #3
    Hi Pablo,

    Yes, you could use KeyMap.

    Here is a full sample.

    Example
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
        <ext:ResourceManager runat="server" />
        <ext:KeyMap runat="server" Target="={Ext.isGecko ? Ext.getDoc() : Ext.getBody()}">
            <ext:KeyBinding StopEvent="true">
                <Keys>
                    <ext:Key Code="ENTER" />
                </Keys>
                <Listeners>
                    <Event Handler="Button1.fireEvent('click');" />
                </Listeners>
            </ext:KeyBinding>
        </ext:KeyMap>
        <ext:TextField runat="server" />
        <ext:TextField runat="server" />
        <ext:Button 
            ID="Button1" 
            runat="server" 
            Text="Submit" 
            AutoPostBack="true" />
        </form>
    </body>
    </html>
  4. #4
    To submit a form without hard postback you could use the following code:
    Ext.getDom("form1").submit()

Similar Threads

  1. Replies: 1
    Last Post: Jul 25, 2012, 9:52 AM
  2. Replies: 4
    Last Post: Oct 10, 2011, 4:28 PM
  3. [CLOSED] Submit gridpanel data in form submit
    By jchau in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Jul 14, 2010, 7:25 PM
  4. [CLOSED] TextField SpecialKey Submit and Enter/Backspace
    By macap in forum 1.x Legacy Premium Help
    Replies: 8
    Last Post: Apr 28, 2010, 4:20 PM
  5. Map Enter Key to Button Submit
    By mathec in forum 1.x Help
    Replies: 1
    Last Post: Jan 20, 2009, 1:25 PM

Tags for this Thread

Posting Permissions