jQuery call __doPostBack on LinkButton

Mark Richman picture Mark Richman · Aug 4, 2010 · Viewed 46.2k times · Source

I have a LinkButton that I need to perform a click on to cause a postback. The actual link target is:

javascript:__doPostBack('ctl00$c1$btnRefreshGrid','');

Clicking the link does perform the postback, as verified by a breakpoint in the code-behind. Also pasting javascript:__doPostBack('ctl00$c1$btnRefreshGrid','') in the address bar of the browser works with the same effect.

I've tried the following with no effect at all:

__doPostBack('ctl00$c1$btnRefreshGrid','');    
$('#ctl00$c1$btnRefreshGrid').click();
$('#ctl00$c1$btnRefreshGrid').trigger('click');
eval($('#ctl00$c1$btnRefreshGrid').attr("href"));

I've tried using both <%= btnRefreshGrid.UniqueID %> and <%= btnRefreshGrid.ClientID %> to generate the selector.

Answer

Markive picture Markive · Nov 8, 2011

You were close, this works in Firefox:

 function clickMyButton() {
   javascript:__doPostBack('<%= MYBUTTONID.UniqueID %>','')
};