Reputation: 2597
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?
Upvotes: 0
Views: 309
Reputation: 50728
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.
Upvotes: 1
Reputation: 11658
Just call __doPostaBack
function. Here some references:
Upvotes: 2
Reputation: 62392
You can trigger click events by calling .click()
with no params..
$('button').click() //<-- calls any attached click event.
Upvotes: 1