Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why this button doesn't cause triple postback?

We have developed a page with a asp.net and debugging it accidentally we have discovered on our page button with the next code on onclik attribute

onclick="__doPostBack('ctl00$FormPlace$m_userTaskMarkAsUnreadButton',''); __doPostBack('ctl00$FormPlace$m_userTaskMarkAsUnreadButton','');WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$FormPlace$m_userTaskMarkAsUnreadButton", "", true, "", "", false, false))"

It seems that the button do three postbacks but when we click it only cause on postback. With this code seems that de button will cause three postbacks!!

We have try it with Internet Explorer and Firefox and the button only cause on postback always. Are browsers who avoid that the button do three postback ? Or Is Asp.net server who avoid the three postback? We don't understand why the button behaves correctly if onclick attribute has three call to do Postbacks.

Thanks

like image 667
focus Avatar asked Sep 17 '26 01:09

focus


2 Answers

If the first JavaScript function called causes the page to POST your data (not using an XMLHttpRequest), a new page is loaded and the execution of your JavaScript stops.

like image 138
Marcel Korpel Avatar answered Sep 18 '26 13:09

Marcel Korpel


The first __doPostback will post the page immediately. The remaining two statements will never be executed.

like image 42
riffnl Avatar answered Sep 18 '26 15:09

riffnl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!