0

I have a keyboard-controlled menu which I did with jquery (When I press down, it marks second option and so on...)

But after I select the option I need, I want to click enter to call the button's OnClick method as if the user really clicked it. Which means I have to do a postback.

how do I do that?

3 Answers 3

2

Just call __doPostaBack function. Here some references:

  1. Doing or Raising Postback using __doPostBack() function from Javascript in Asp.Net
  2. Easily refresh an UpdatePanel, using JavaScript
Sign up to request clarification or add additional context in comments.

Comments

1

As @jondavidjohn said, you can use the click() method. Otherwise, you can use

__doPostBack("<control unique ID>", "<command name/arg appended>");

Pass in the unique ID of the control, not the client ID, and the second param is the command name. If you also need the arg, you append it to the command name with a separator like $ or :.

You can check that this happens by doing the following:

Request.Form.Get("__EVENTTARGET") == button.UniqueID

This method essentially sets the __EVENTTARGET and __EVENTARGUMENT form fields.

HTH.

Comments

1

You can trigger click events by calling .click() with no params..

$('button').click()  //<-- calls any attached click event.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.