views:

344

answers:

2

I have a page with part of a listview control inside an update panel. When a button is clicked in the listview I modify some data and call this.databind to refresh the data. It appears that the page load event is still firing even though the control is inside an update panel. I am wondering why the page load event is firing? Is it due to calling this.databind on the listview_onitemcommand event?

+5  A: 

An UpdatePanel invokes an entire request lifecycle on the server. It is exactly the same as if you'd clicked the button in a normal synchronous page. OnInit, OnLoad, Click_Handler, and Render all execute. The entire page is rendered to HTML and sent back to the browser through the AJAX call of the UpdatePanel. The only difference is that when the UpdatePanel receives the results (the entire HTML output of your page, like normal) it slices out just the part relevant to itself and replaces the DOM with that HTML, and throws the rest away. (It also updates/replaces the ViewState)

Rex M
not quite, the render method is invoked only for the controls within any update panels that are being updated for the current request. So the entire HTML for a page is not sent back to the client.
Daniel
A: 

If you wish to get rid of the UpdatePanel, I recommend reading this article

I think getting rid of the UpdatePanel was the most wonderful Ajax decision I ever made.

Cyril Gupta
The UpdatePanel has its faults, but your article is unfairly derisive and doesn't take into account the possibility that a UP is a very reasonable tool for getting some things done quickly.
Rex M
Whenever I've used the updatepanel I've always hated it. Yes it kinds of really bakes my noodle. If you're still using it, I kind of feel sorry for your projects.
Cyril Gupta