Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery call __doPostBack on LinkButton

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.

like image 975
Mark Richman Avatar asked Aug 04 '10 15:08

Mark Richman


1 Answers

You were close, this works in Firefox:

 function clickMyButton() {
   javascript:__doPostBack('<%= MYBUTTONID.UniqueID %>','')
};
like image 113
Markive Avatar answered Sep 22 '22 21:09

Markive