473,385 Members | 2,014 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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.

Feb 3 '06 #1
3 1643
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.


Feb 3 '06 #2
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

<er****@gmail.com> wrote in message
news:11**********************@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.

Feb 3 '06 #3
He's writing in vb.net not c#

--
Terry Burns
http://TrainingOn.net
"ThunderMusic" <NOdanlatSPAM@hotmaildotcom> wrote in message
news:uC**************@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

<er****@gmail.com> wrote in message
news:11**********************@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.


Feb 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Ibc | last post by:
Hi, I am having trouble setting class and session variables in the Page_Load function in C#. No matter what I set the variables to in Page_Load they are null when I try to access them in other...
1
by: bminder | last post by:
In the asp.net pages below, Common.vb has an overridable Page_Load sub. In the consuming page, Two.aspx, the Page_Load sub is inherited, but for some reason it (Overrides Sub Page_Load) executes...
13
by: David Lozzi | last post by:
Howdy My following script is not processing at all! <script runat="server"> Sub Page_Load(sender as Object, e as EventArgs) lblWelcome.text = "hello" End Sub </script>
14
by: V. Jenks | last post by:
I'm a little rusty having not touched .NET for 6 months and I can't remember why Page_Load is happening twice in this code: private void Page_Load(object sender, System.EventArgs e) {...
5
by: Andy | last post by:
Hi all, I have a site with the following architecture: Common.Web.dll - Contains a CommonPageBase class which inherits System.Web.UI.Page myadd.dll - Contains PageBase which inherits...
12
by: Nathan Sokalski | last post by:
What is the difference between the Page_Init and Page_Load events? When I was debugging my code, they both seemed to get triggered on every postback. I am assuming that there is some difference,...
2
by: Richard Lionheart | last post by:
Hi All, I adapted some sample code from w3schools.com and tried to adapt it to .NET to test dynamic processing in a WebForm. The client page that got generated produced everything that was...
9
by: coltrane | last post by:
I am just learing ASP.Net and my first app has a simple Page_Load that just sets a variable. This does not seem to be called. The following is a snippet of the page: <script runat="server"...
4
by: David C | last post by:
I spent the last four hours trying to figure out why Page_Load would execute twice. Even stranger was that everything within if (! IsPostBack){....} executed twice as well. There is no rhyme or...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.