Enter Key triggers onClick event

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dreea
    New Member
    • Aug 2007
    • 37

    Enter Key triggers onClick event

    Hello

    I have designed a control that consists of a textarea and a button. When the user writes text in the textarea and the Enter key is pressed then the onClick event of the button is triggered. Is there any way I can make the Enter key not trigger the onClick event of the button. Or in the buttonclicked event handler to determine if the button was clicked or the enter was pressed?

    Any help would be very appreciated
    Thanks in advance
  • iam_clint
    Recognized Expert Top Contributor
    • Jul 2006
    • 1207

    #2
    what exactly are you trying to do here... you may want to go with onfocus().... you can also check if the charcode pressed was 14

    Comment

    • Dreea
      New Member
      • Aug 2007
      • 37

      #3
      Originally posted by iam_clint
      what exactly are you trying to do here... you may want to go with onfocus().... you can also check if the charcode pressed was 14
      I don't want the enter key to trigger _btn_Click
      Code:
             void _btn_Click(object sender, EventArgs e)
              {
                  .....
              }
      where exactly i get the charcode pressed? I need to mention that the textbox is actually a gaia control so I don't have access to its code to add a keyPressed event handler

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        Originally posted by Dreea
        I don't want the enter key to trigger _btn_Click
        Code:
               void _btn_Click(object sender, EventArgs e)
                {
                    .....
                }
        where exactly i get the charcode pressed? I need to mention that the textbox is actually a gaia control so I don't have access to its code to add a keyPressed event handler
        I would recommend asking the people who created the control how to prevent this from happening. If it was a regular text area you would not be experiencing this problem.

        -Frinny

        Comment

        Working...