Asynchronous. Does postbacks call page_Init? (WITH#)

I have a very strange problem ...

I have a regular ASP.Net webpage with the function page_init and page_load. This is my understanding (I look everywhere) that page_init is called when the first page loads (like in, it is never called in the postback), and page_load is called anytime when something happens to the page. (It’s very difficult to find any information about this except for dead links and stuff about the page life cycle)

Well, I have an update panel containing other update panels and other various controls. Each time I edit one of these controls, an async postback occurs, but instead of only calling page_load, page_init is also called, which is not supposed (and did not happen before the large base was changed)

So, I would like to know everything that this behavior can cause, or simply if my idea of ​​how page events are raised is incorrect.

+4
source share
4 answers

I think you have the wrong idea of ​​the page load life cycle. The OnInit event is fired on every request. Having the Page_Init method in your code behind is a shorthand way for connecting OnInit pages.

Now I believe that you are confusing this IsPostBack property, which will be set to true if the page returns to itself, i.e. when you press the button etc. My guess is that what you need to do is add an if in your Page_Init method, i.e.

if(!IsPostBack){ //Do something to to update the UI } 
+4
source

Page_Init definitely called on every page hit, on the reverse side or not, just like Page_Load .

The misconception that Page_Init does not cause a call on every request seems to be common.

Are you sure this did not happen before the β€œbig code change” changed?

+3
source

My suggestion is that you create a simple example of what you are trying to do on a completely new scratch page based on these rules.

http://msdn.microsoft.com/en-us/library/ms178472.aspx

Keep adding complexity as it is now until it breaks.

It would be difficult to diagnose your problem without code.

0
source

Each time your Page_Init, as well as Page_Load both methods are called.

0
source

All Articles