Re: What is function pageLoad()
- From: "AAaron123" <aaaron123@xxxxxxxxxxxxxx>
- Date: Wed, 4 Feb 2009 15:26:52 -0500
I like #1 better than the way I did it in the constructor.
Thanks
"George" <noemail@xxxxxxxxxxx> wrote in message
news:udznJVwhJHA.4372@xxxxxxxxxxxxxxxxxxxxxxx
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.
"AAaron123" <aaaron123@xxxxxxxxxxxxxx> wrote in message
news:eqUHnLuhJHA.760@xxxxxxxxxxxxxxxxxxxxxxx
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
"AAaron123" <aaaron123@xxxxxxxxxxxxxx> wrote in message
news:OyrV5FZfJHA.5496@xxxxxxxxxxxxxxxxxxxxxxx
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
"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@xxxxxxxxxxxxxxxxxx> wrote
in message news:uO5VCnWfJHA.3708@xxxxxxxxxxxxxxxxxxxxxxx
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! |
*************************************************
"AAaron123" <aaaron123@xxxxxxxxxxxxxx> wrote in message
news:%23vPBTtKfJHA.5244@xxxxxxxxxxxxxxxxxxxxxxx
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
"Cowboy (Gregory A. Beamer)" <NoSpamMgbworld@xxxxxxxxxxxxxxxxxx> wrote
in message news:uXfu26JfJHA.3792@xxxxxxxxxxxxxxxxxxxxxxx
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! |
*************************************************
"AAaron123" <aaaron123@xxxxxxxxxxxxxx> wrote in message
news:%23N%23uyk$eJHA.5316@xxxxxxxxxxxxxxxxxxxxxxx
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
.
- References:
- Re: What is function pageLoad()
- From: AAaron123
- Re: What is function pageLoad()
- From: George
- Re: What is function pageLoad()
- Prev by Date: Re: DoPostBack sometimes isn't in HTML
- Next by Date: Re: DoPostBack sometimes isn't in HTML
- Previous by thread: Re: What is function pageLoad()
- Next by thread: SqlMembership Provider without dbo owner
- Index(es):
Relevant Pages
|