What is function pageLoad()

  • Thread starter Thread starter AAaron123
  • Start date Start date
A

AAaron123

I got from ms an .aspx file that contains a pageLoad() JavaScript function

I put an alert in it and I can see that it does run.

What calls it?

It is not referenced in the code, but it does execute.

Is it a page load event that is automatically wired as a client side event?

If so, are there other such events.

Google and VS Help give many hits but they seem to relate to Page.Load or
the words "page load"



So, I copied into another .aspx file and it does NOT execute.

They both have AutoEventWireup="false" and are both content files for the
same master.



Why does it work in one but not the other?



Thanks
 
I got from ms an .aspx file that contains a pageLoad() JavaScript function

I put an alert in it and I can see that it does run.

What calls it?

It is not referenced in the code, but it does execute.

Is it a page load event that is automatically wired as a client side event?

If so, are there other such events.

Google and VS Help give many hits but they seem to relate to Page.Load or
the words "page load"

So, I copied into another  .aspx file and it does NOT execute.

They both have AutoEventWireup="false" and are both content files for the
same master.

Why does it work in one but not the other?

Thanks

It must be referenced somewhere. If it is an aspx, it can be done in
the code-behind. Try to look in the generated source code of the final
page in the browser (right click - view source).

Hope this helps
 

I used the word "code" (probably incorrectly) to include the .aspx file
contents.
It appears no place in a search of the entire solution.
I wish I could breakpoint and check a call stack.
Actually, it's a context file with two data areas, one for the header
(containing pageLoad) and one for the body.

Thanks
 
I'm playing around with Virtual Earth and searching on the ms site for it
brought me to an AJAX site which had:

To handle the load and unload events of the Application object, you do not
have to explicitly bind a handler to the event. Instead, you can create
functions that use the reserved names pageLoad and pageUnload.

So I'm guessing that AJAX uses these functions if they are present and VE
uses AJAX.

Does that make sense to anyone?

I need to read some more but wanted to pass this on since I didn't know
mentioning VE was important in my first post, and didn't mention it.
 
I'm playing around with Virtual Earth and searching on the ms site for it
brought me to an AJAX site which had:

To handle the load and unload events of the Application object, you do not
have to explicitly bind a handler to the event. Instead, you can create
functions that use the reserved names pageLoad and pageUnload.

So I'm guessing that AJAX uses these functions if they are present and VE
uses AJAX.

Does that make sense to anyone?

I need  to read some more but wanted to pass this on since I didn't know
mentioning VE was important in my first post, and didn't mention it.

Well, as you can see it is from MS AJAX Library. These functions are
automatically attached when a page contains ASP.NET AJAX server
controls.
 
Thanks

I'm playing around with Virtual Earth and searching on the ms site for it
brought me to an AJAX site which had:

To handle the load and unload events of the Application object, you do not
have to explicitly bind a handler to the event. Instead, you can create
functions that use the reserved names pageLoad and pageUnload.

So I'm guessing that AJAX uses these functions if they are present and VE
uses AJAX.

Does that make sense to anyone?

I need to read some more but wanted to pass this on since I didn't know
mentioning VE was important in my first post, and didn't mention it.

Well, as you can see it is from MS AJAX Library. These functions are
automatically attached when a page contains ASP.NET AJAX server
controls.
 
It is a function name built into AJAX to make things simpler for you to load
client side variables when you are using AJAX. There is also a pageUnload,
if you need clean up. In most cases, these routines are not taken advantage
of by developers. I have, however, seen it used to load Silverlight, which
is a bit creative.

When the page is compiled, the pageLoad event gets wired up to
Sys.Application.Load. This is very similar to how Page_Load is wired to
Page.Load in ASP.NET code.

--
Gregory A. Beamer
MVP; MCP: +I, Se, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*************************************************
| Think outside the box! |
*************************************************
 
I have a question about Page_Load. If I have AutoEventWireup="false"

for the Page_Load event to be raised in C# don't I have to register the
event?

I'm not sure "register" is the correct word, but it seems I remember a
statement, something like:

??? += ???

If so where do I put the statement?

Thanks a lot
 
With the standard events you do not need to go through the hoops of
registration, as it is done for you. For other event handlers, you do have
to connect them, either declaratively or with the ??? += ??? format.

--
Gregory A. Beamer
MVP; MCP: +I, Se, SD, DBA

Blog:
http://feeds.feedburner.com/GregoryBeamer

*************************************************
| Think outside the box! |
*************************************************
 
Just one more time because I think my experience shows the Page_Load event
does not fire if AutoEventWireup="false".

If I'm correct then I don't know the format to register the event and don't
know where to put the register command.

Thanks

PS I'll check again to see if the event fires
 
I just got back to this.

I have an aspx file that contains AutoEventWireup="false"
If I double click in the design mode it open the .cs file pointing to the
public void Page_Load method.



But when I run in debug mode that method is not called.

So I add a constructor:

public FileForm()

{

this.Load += Page_Load;

}

And Page_Load does run.

So it appears that with AutoEventWireup="false"
and c# I need to register Page_load in the constructor.

Is that your understanding??

Also for other methods like Page_Unload?



Thanks
 
You correct in that you need to wire up your events.

with C# you have 3 options.

1 (best). override OnLoad method of the base Page class.
so it looks like this
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
...your code here
}

Plus: somewhat faster and convenient sine it's less code
Minus: Method must be named OnLoad

2 (ok). Wire up it to Page.Load event
Load += Page_Load;

Plus: You can name your method anything you want and you can wire up many
different methods.
Minus: You need to no forget write that line of code

3(worst). Use AutoEventWireup = true.
This is worst since it's using reflection to find all available methods on a
form and wire them up as in #2. but wasting a lot of runtime.

My advice: Always keep AutoEventWireup = false and use #1 method.

George.
 
Back
Top