|
 |
aspx thread: What if Page_Load isn't getting called?
Message #1 by "George Walley" <booyah@m...> on Wed, 9 Jan 2002 17:01:30
|
|
Am I right in saying that if you have a custom-defined Page_Load()
function in the SCRIPT section of an aspx file, it should get called when
served up by the web server?
do you have to inherit an object or something to make Page_Load work?
I'm doing a simple static databinding in my Page_Load function (for test
purposes) and when I run it even in visual studio .net in debug mode, it
never gets to the function and thus on the web, the dropdown never gets
filled.
thanks.
-george
Message #2 by "Albert Davis" <albertdavis@h...> on Wed, 09 Jan 2002 12:01:45 -0500
|
|
It depends on how you are accomplishing this task. 2 different ways right
of the bat is you either wire up the event and supply your delegate that is
to be called through multicasting or you override the Page Class's protected
virtual OnLoad(EventArgs e){} method. In these 2 most commonly used
approachs your loading methed will be called... Can you give a code sample
on how your currently trying to achieve this which is giving you problems?
Al
>From: "George Walley" <booyah@m...>
>Reply-To: "ASP+" <aspx@p...>
>To: "ASP+" <aspx@p...>
>Subject: [aspx] What if Page_Load isn't getting called?
>Date: Wed, 9 Jan 2002 17:01:30
>
>Am I right in saying that if you have a custom-defined Page_Load()
>function in the SCRIPT section of an aspx file, it should get called when
>served up by the web server?
>
>do you have to inherit an object or something to make Page_Load work?
>
>I'm doing a simple static databinding in my Page_Load function (for test
>purposes) and when I run it even in visual studio .net in debug mode, it
>never gets to the function and thus on the web, the dropdown never gets
>filled.
>
>thanks.
>
>-george
_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com
Message #3 by "Brian Bilbro" <bbilbro@h...> on Wed, 9 Jan 2002 12:07:27 -0500
|
|
----- Original Message -----
From: "George Walley" <booyah@m...>
Sent: 01/09/2002 5:01 PM
> Am I right in saying that if you have a custom-defined Page_Load()
> function in the SCRIPT section of an aspx file, it should get called when
> served up by the web server?
>
> do you have to inherit an object or something to make Page_Load work?
>
> I'm doing a simple static databinding in my Page_Load function (for test
> purposes) and when I run it even in visual studio .net in debug mode, it
> never gets to the function and thus on the web, the dropdown never gets
> filled.
If you created the page in VS.NET it automatically adds the directive
AutoEventWireup="false".
This will keep asp.net from adding the "wireup" code to call the Page_load
(and other events) at runtime for the .aspx page. VS.NET does this because
it thinks everything is in the code-behind. Try setting the
AutoEventWireup="true" and then running your page.
HTHs,
Brian
Message #4 by "George Walley" <booyah@m...> on Wed, 9 Jan 2002 19:04:43
|
|
Brian - Thanks! That did it and answered some other questions of mine as
well! I also found that if I constructed the Page_Load() function in
my .aspx file differently, it would also work as below:
Private Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
...
End Sub
INSTEAD OF (without setting AutoEventWireUp = true)
Sub Page_Load(oSource As Object, oArgs as EventArgs)
...
End Sub
Does that seem consistent with what AutoEventWireUp does?
-george
> If you created the page in VS.NET it automatically adds the directive
> AutoEventWireup="false". This will keep asp.net from adding
> the "wireup" code to call the Page_load (and other events) at runtime
> for the .aspx page. VS.NET does this because it thinks everything is
> in the code-behind. Try setting the AutoEventWireup="true" and then
> running your page.
|
|
 |