When a common web page is initially loaded, we usually use if (! Page. ispostback) to determine whether the page is first loaded or returned. For the pageload event in the JS script of the ASP. NET Ajax client, it also has the pageload event that is initially loaded or triggered by sending back.
I just talked with the wrinkle key about how to determine the specific issue. The idea is similar to mine. It is identified by a global variable. However, after some research, it was found that it was not necessary. Run the following code:
1 function pageload (sender, E)
2 {
3 // here, E. get_ispartialload () is used to determine whether it is initial loading or sending back.
4 If (E. get_ispartialload ())
5 {
6 SYS. webforms. pagerequestmanager. getinstance (). add_initializerequest (initrequesthandler );
7 SYS. webforms. pagerequestmanager. getinstance (). add_beginrequest (beginrequesthandler );
8 SYS. webforms. pagerequestmanager. getinstance (). add_endrequest (endrequesthandler );
9}
10}
Only E. get_ispartialload () is OK.
In addition, you can test the sequence of several events in SYS. Web. pagerequestmanager. getinstance () in the following code:
Initializerequest → beginrequest → send data to the server → receive data → pageloading → pageload → endrequest 1 function pageload (sender, E)
2 {
3 if (E. get_ispartialload () = false)
4 {
5 SYS. webforms. pagerequestmanager. getinstance (). add_initializerequest (initrequesthandler );
6 SYS. webforms. pagerequestmanager. getinstance (). add_pageloading (pageloadinghandler );
7 SYS. webforms. pagerequestmanager. getinstance (). add_pageloaded (pageloadedhandler );
8 SYS. webforms. pagerequestmanager. getinstance (). add_beginrequest (beginrequesthandler );
9 SYS. webforms. pagerequestmanager. getinstance (). add_endrequest (endrequesthandler );
10}
11}
12
13 function pageloadinghandler (sender, E)
14 {
15 alert ("pageloading ");
16}
17
18 function pageloadedhandler (sender, E)
19 {
20 alert ("pageloaded ");
21}
22 function initrequesthandler (sender, E)
23 {
24 alert ("initrequesthandler ");
25}
26
27 function beginrequesthandler (sender, E)
28 {
29 alert ("beginrequesthandler ");
30}
31
32 function endrequesthandler (sender, E)
33 {
34 alert ("endrequesthandler ");
35}