Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP .Net (http://www.velocityreviews.com/forums/f29-asp-net.html)
-   -   Page_Load is not executed in codebehind (http://www.velocityreviews.com/forums/t118856-page_load-is-not-executed-in-codebehind.html)

ericw3@gmail.com 02-03-2006 06:41 PM

Page_Load is not executed in codebehind
 
I am testing the code snippets of John Peterson (
http://www.asp101.com/articles/john/...vs/default.asp ).

I have WebForm2.vb as follows:

Public Class WebForm2
Inherits System.Web.UI.Page
Protected WithEvents Button1 As System.Web.UI.WebControls.Button
Protected WithEvents Label1 As System.Web.UI.WebControls.Label

Private Sub Page_Load(sender As System.Object, e As System.EventArgs)
If Not Page.IsPostBack Then
Response.Write("Yeah, I got you!")
end If
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
Response.Write("Aha, there you are!")
Label1.Text = "I was clicked at: " & System.DateTime.Now

End Sub
End Class

And I have WebForm2.aspx as follows:

<%@ Page Language="vb" AutoEventWireup="false"
Src="WebForm2.vb" Inherits="WebForm2"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>WebForm2 Code-Behind Test</title>
</head>
<body>
<form id="Form1" method="post" runat="server">
<asp:Button id="Button1" runat="server" Text="Button">
</asp:Button>
<br />
<br />
<asp:Label id="Label1" runat="server">Label</asp:Label>
</form>
</body>
</html>

When I check out WebForm2.aspx from the browser, I noticed that the Sub
Page_Load is not executed. The Sub Button1_Click is executed upon
click.

If I put the subs in WebForm2.aspx and of course make minor changes
accordingly, the Page_Load Sub gets executed when I check out
WebForm2.aspx from the browser.

What is going on? Can anyone please teach me? Thanks.


ericw3@gmail.com 02-03-2006 06:44 PM

Re: Page_Load is not executed in codebehind
 
I got it, I need the suffix Handles MyBase.Load


eri...@gmail.com wrote:
> I am testing the code snippets of John Peterson (
> http://www.asp101.com/articles/john/...vs/default.asp ).
>
> I have WebForm2.vb as follows:
>
> Public Class WebForm2
> Inherits System.Web.UI.Page
> Protected WithEvents Button1 As System.Web.UI.WebControls.Button
> Protected WithEvents Label1 As System.Web.UI.WebControls.Label
>
> Private Sub Page_Load(sender As System.Object, e As System.EventArgs)
> If Not Page.IsPostBack Then
> Response.Write("Yeah, I got you!")
> end If
> End Sub
>
> Private Sub Button1_Click(ByVal sender As System.Object, _
> ByVal e As System.EventArgs) Handles Button1.Click
> Response.Write("Aha, there you are!")
> Label1.Text = "I was clicked at: " & System.DateTime.Now
>
> End Sub
> End Class
>
> And I have WebForm2.aspx as follows:
>
> <%@ Page Language="vb" AutoEventWireup="false"
> Src="WebForm2.vb" Inherits="WebForm2"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>
> <html>
> <head>
> <title>WebForm2 Code-Behind Test</title>
> </head>
> <body>
> <form id="Form1" method="post" runat="server">
> <asp:Button id="Button1" runat="server" Text="Button">
> </asp:Button>
> <br />
> <br />
> <asp:Label id="Label1" runat="server">Label</asp:Label>
> </form>
> </body>
> </html>
>
> When I check out WebForm2.aspx from the browser, I noticed that the Sub
> Page_Load is not executed. The Sub Button1_Click is executed upon
> click.
>
> If I put the subs in WebForm2.aspx and of course make minor changes
> accordingly, the Page_Load Sub gets executed when I check out
> WebForm2.aspx from the browser.
>
> What is going on? Can anyone please teach me? Thanks.



ThunderMusic 02-03-2006 07:06 PM

Re: Page_Load is not executed in codebehind
 
that or the following line in "InitializeComponent" :

this.Load += new System.EventHandler(this.Page_Load);

the same pattern (line above in InitializeComponent") will allow you to
handle many other events along the way.

I hope it helps

ThunderMusic

<ericw3@gmail.com> wrote in message
news:1138992279.637969.315690@g14g2000cwa.googlegr oups.com...
>I got it, I need the suffix Handles MyBase.Load
>
>
> eri...@gmail.com wrote:
>> I am testing the code snippets of John Peterson (
>> http://www.asp101.com/articles/john/...vs/default.asp ).
>>
>> I have WebForm2.vb as follows:
>>
>> Public Class WebForm2
>> Inherits System.Web.UI.Page
>> Protected WithEvents Button1 As System.Web.UI.WebControls.Button
>> Protected WithEvents Label1 As System.Web.UI.WebControls.Label
>>
>> Private Sub Page_Load(sender As System.Object, e As System.EventArgs)
>> If Not Page.IsPostBack Then
>> Response.Write("Yeah, I got you!")
>> end If
>> End Sub
>>
>> Private Sub Button1_Click(ByVal sender As System.Object, _
>> ByVal e As System.EventArgs) Handles Button1.Click
>> Response.Write("Aha, there you are!")
>> Label1.Text = "I was clicked at: " & System.DateTime.Now
>>
>> End Sub
>> End Class
>>
>> And I have WebForm2.aspx as follows:
>>
>> <%@ Page Language="vb" AutoEventWireup="false"
>> Src="WebForm2.vb" Inherits="WebForm2"%>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>>
>> <html>
>> <head>
>> <title>WebForm2 Code-Behind Test</title>
>> </head>
>> <body>
>> <form id="Form1" method="post" runat="server">
>> <asp:Button id="Button1" runat="server" Text="Button">
>> </asp:Button>
>> <br />
>> <br />
>> <asp:Label id="Label1" runat="server">Label</asp:Label>
>> </form>
>> </body>
>> </html>
>>
>> When I check out WebForm2.aspx from the browser, I noticed that the Sub
>> Page_Load is not executed. The Sub Button1_Click is executed upon
>> click.
>>
>> If I put the subs in WebForm2.aspx and of course make minor changes
>> accordingly, the Page_Load Sub gets executed when I check out
>> WebForm2.aspx from the browser.
>>
>> What is going on? Can anyone please teach me? Thanks.

>




Terry Burns 02-03-2006 08:21 PM

Re: Page_Load is not executed in codebehind
 
He's writing in vb.net not c#



--
Terry Burns
http://TrainingOn.net
"ThunderMusic" <NOdanlatSPAM@hotmaildotcom> wrote in message
news:uCFLMUPKGHA.1728@TK2MSFTNGP14.phx.gbl...
> that or the following line in "InitializeComponent" :
>
> this.Load += new System.EventHandler(this.Page_Load);
>
> the same pattern (line above in InitializeComponent") will allow you to
> handle many other events along the way.
>
> I hope it helps
>
> ThunderMusic
>
> <ericw3@gmail.com> wrote in message
> news:1138992279.637969.315690@g14g2000cwa.googlegr oups.com...
>>I got it, I need the suffix Handles MyBase.Load
>>
>>
>> eri...@gmail.com wrote:
>>> I am testing the code snippets of John Peterson (
>>> http://www.asp101.com/articles/john/...vs/default.asp ).
>>>
>>> I have WebForm2.vb as follows:
>>>
>>> Public Class WebForm2
>>> Inherits System.Web.UI.Page
>>> Protected WithEvents Button1 As System.Web.UI.WebControls.Button
>>> Protected WithEvents Label1 As System.Web.UI.WebControls.Label
>>>
>>> Private Sub Page_Load(sender As System.Object, e As System.EventArgs)
>>> If Not Page.IsPostBack Then
>>> Response.Write("Yeah, I got you!")
>>> end If
>>> End Sub
>>>
>>> Private Sub Button1_Click(ByVal sender As System.Object, _
>>> ByVal e As System.EventArgs) Handles Button1.Click
>>> Response.Write("Aha, there you are!")
>>> Label1.Text = "I was clicked at: " & System.DateTime.Now
>>>
>>> End Sub
>>> End Class
>>>
>>> And I have WebForm2.aspx as follows:
>>>
>>> <%@ Page Language="vb" AutoEventWireup="false"
>>> Src="WebForm2.vb" Inherits="WebForm2"%>
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
>>>
>>> <html>
>>> <head>
>>> <title>WebForm2 Code-Behind Test</title>
>>> </head>
>>> <body>
>>> <form id="Form1" method="post" runat="server">
>>> <asp:Button id="Button1" runat="server" Text="Button">
>>> </asp:Button>
>>> <br />
>>> <br />
>>> <asp:Label id="Label1" runat="server">Label</asp:Label>
>>> </form>
>>> </body>
>>> </html>
>>>
>>> When I check out WebForm2.aspx from the browser, I noticed that the Sub
>>> Page_Load is not executed. The Sub Button1_Click is executed upon
>>> click.
>>>
>>> If I put the subs in WebForm2.aspx and of course make minor changes
>>> accordingly, the Page_Load Sub gets executed when I check out
>>> WebForm2.aspx from the browser.
>>>
>>> What is going on? Can anyone please teach me? Thanks.

>>

>
>





All times are GMT. The time now is 02:07 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.