Enter Key H*ll, control enter key submit button

Discussion in 'ASP .Net Web Controls' started by BrianDH, Jan 12, 2005.

  1. BrianDH

    BrianDH Guest

    Hi
    VB.Net code Behind, Web form.
    I am looking for a way to stop my web form application
    from firering a button click when the user hits the Enter
    key.
    I only want to button to bubmit, or exit or clear when
    they click the button not in random when they hit the
    enter key.

    Thanks for the help.
    BrianDH
     
    BrianDH, Jan 12, 2005
    #1
    1. Advertising

  2. BrianDH

    BrianDh Guest

    Thank you!!!!!!!!

    Damn microsoft! Now I have to write vb.net, and
    javascript in one app. Yep we are moving forward! ;-D

    Thanks ;-)

    >-----Original Message-----
    >On Wed, 12 Jan 2005 07:45:29 -0800, "BrianDH"
    ><> wrote:
    >
    >>Hi
    >>VB.Net code Behind, Web form.
    >>I am looking for a way to stop my web form application
    >>from firering a button click when the user hits the

    Enter
    >>key.
    >>I only want to button to bubmit, or exit or clear when
    >>they click the button not in random when they hit the
    >>enter key.
    >>
    >>Thanks for the help.
    >>BrianDH

    >
    >Add this little script to the page:
    >
    > <script language="javascript">
    > function BlockEnter()
    > {
    > if (window.event.keyCode == 13)
    > {
    > window.event.keyCode = 0;
    > };
    > };
    > </script>
    >
    >And add
    >onKeyPress="BlockEnter()"
    >to the body tag
    >
    >Leon.
    >.
    >
     
    BrianDh, Jan 12, 2005
    #2
    1. Advertising

  3. BrianDH

    Bob Lehmann Guest

    How is your problem related to Microsoft? The enter key behavior is present
    in all modern browsers.

    Bob Lehmann

    "BrianDh" <> wrote in message
    news:213d01c4f8d2$d2b42b20$...
    > Thank you!!!!!!!!
    >
    > Damn microsoft! Now I have to write vb.net, and
    > javascript in one app. Yep we are moving forward! ;-D
    >
    > Thanks ;-)
    >
    > >-----Original Message-----
    > >On Wed, 12 Jan 2005 07:45:29 -0800, "BrianDH"
    > ><> wrote:
    > >
    > >>Hi
    > >>VB.Net code Behind, Web form.
    > >>I am looking for a way to stop my web form application
    > >>from firering a button click when the user hits the

    > Enter
    > >>key.
    > >>I only want to button to bubmit, or exit or clear when
    > >>they click the button not in random when they hit the
    > >>enter key.
    > >>
    > >>Thanks for the help.
    > >>BrianDH

    > >
    > >Add this little script to the page:
    > >
    > > <script language="javascript">
    > > function BlockEnter()
    > > {
    > > if (window.event.keyCode == 13)
    > > {
    > > window.event.keyCode = 0;
    > > };
    > > };
    > > </script>
    > >
    > >And add
    > >onKeyPress="BlockEnter()"
    > >to the body tag
    > >
    > >Leon.
    > >.
    > >
     
    Bob Lehmann, Jan 12, 2005
    #3
  4. BrianDH wrote:

    > I am looking for a way to stop my web form application
    > from firering a button click when the user hits the Enter
    > key.
    >
    > I only want to button to bubmit, or exit or clear when
    > they click the button not in random when they hit the
    > enter key.


    If it is because of the buttonorder making trouble, control what is
    submitted when pressing enter :

    Public Shared Sub SetDefaultButton(ByRef objTextControl As TextBox,
    ByRef objDefaultButton As Button)
    objTextControl.Attributes.Add("onkeydown", "if (event.keyCode == 13)
    {document.getElementById('" + objDefaultButton.ClientID + "').click();
    return false;} else return true;")
    End Sub
    --
    /Anders
     
    Anders Matthiessen, Jan 12, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Megha Vishwanath
    Replies:
    2
    Views:
    9,941
    tutorialsmaster
    Oct 2, 2009
  2. Guest
    Replies:
    2
    Views:
    1,670
    Guest
    Oct 25, 2004
  3. Matt
    Replies:
    1
    Views:
    560
    Michael Winter
    Mar 6, 2004
  4. Megha Vishwanath
    Replies:
    3
    Views:
    803
    Megha Vishwanath
    Jul 20, 2004
  5. HopfZ
    Replies:
    0
    Views:
    625
    HopfZ
    Aug 28, 2006
Loading...

Share This Page