SendKeys.Send("{ENTER}") RRS feed

  • Question

  • User-49671077 posted

    How can send [ENTER] to Textbox in ASP.net and VB.net behind code.

    Exp.: SendKeys.Send("{ENTER}")


    Sunday, December 30, 2018 2:31 PM

All replies

  • User-943250815 posted

    This is totally out of context, a Server do not send commands to your browser.
    A server just send an html code to your browser, any automation on client side should be done with javascript

    Sunday, December 30, 2018 4:09 PM
  • User-49671077 posted

    any idea..

    Sunday, December 30, 2018 8:28 PM
  • User-893317190 posted

    Hi kafsar,

    I'm not clear about what  effect you want to have  through sending [ENTER] to Textbox.

    Do you mean you want to call some method  or  want to trigger some event?

    SendKeys.Send("{ENTER}") seems to be a winform method, and it could  simulate  keyboard entering. If you want to realize the same effect, you had better use javascript.

    javascript has an event named onkeydown,the event will be triggered when the user presses the keyboard.

    In the event you could get what Keyboard button is being pressed.

    For example, you could write your js as follows:  

     function whenInputEnter() {
            document.getElementById("TextBox1").onkeydown = function (e) {
                if (e.keyCode == 13) {

    e.keyCode could represent the keyCode of your keyboard button. 13 is the keyCode of enter.

    You could also directly call the function whenInputEnter like  whenInputEnter();

    Best regards,

    Ackerly Xu

    Monday, December 31, 2018 2:25 AM