Thursday, March 29, 2012

newbie - page load not firing

Using asp.net 2.0. I have a page confirm.aspx:
**********************************
<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false"
CodeFile="confirm.aspx.vb" Inherits="confirm" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
</form>
</body>
</html>
****************************************
*****************
This is my page behind page (confirm.aspx.vb):
Partial Class confirm
Inherits System.Web.UI.Page
Sub Page_Load(ByVal s As Object, ByVal e As EventArgs)
Response.Write("hello")
End Sub
End Class
****************************************
*******
When I confirm.aspx loads in the browser nothing happens. i.e. a blank
page is returned. Shouldn't "hello" be displayed? What am I doing
wrong?Change AutoEventWireup="false" to AutoEventWireup="true" and it should work.
If you're a newbie to .Net from classic asp, note that response.write will
output before all the other content. - i.e. before "<!DOCTYPE.....". But
you'll see that when you run it :)
Jevon
"Steve" <bahram@.iranmania.com> wrote in message
news:1130840485.862653.166360@.g43g2000cwa.googlegroups.com...
> Using asp.net 2.0. I have a page confirm.aspx:
> **********************************
> <%@. Page Language="VB" AutoEventWireup="false"
> CodeFile="confirm.aspx.vb" Inherits="confirm" %>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> </div>
> </form>
> </body>
> </html>
> ****************************************
*****************
> This is my page behind page (confirm.aspx.vb):
>
> Partial Class confirm
> Inherits System.Web.UI.Page
> Sub Page_Load(ByVal s As Object, ByVal e As EventArgs)
> Response.Write("hello")
> End Sub
> End Class
> ****************************************
*******
> When I confirm.aspx loads in the browser nothing happens. i.e. a blank
> page is returned. Shouldn't "hello" be displayed? What am I doing
> wrong?
>
Set AutoEventWireup to True and try.
"Steve" wrote:

> Using asp.net 2.0. I have a page confirm.aspx:
> **********************************
> <%@. Page Language="VB" AutoEventWireup="false"
> CodeFile="confirm.aspx.vb" Inherits="confirm" %>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> </div>
> </form>
> </body>
> </html>
> ****************************************
*****************
> This is my page behind page (confirm.aspx.vb):
>
> Partial Class confirm
> Inherits System.Web.UI.Page
> Sub Page_Load(ByVal s As Object, ByVal e As EventArgs)
> Response.Write("hello")
> End Sub
> End Class
> ****************************************
*******
> When I confirm.aspx loads in the browser nothing happens. i.e. a blank
> page is returned. Shouldn't "hello" be displayed? What am I doing
> wrong?
>
Thank you so much for that. I spent more than 2 needless hours this
morning getting frustrated over this. Thank you so much.
So does that mean the Page_Load event can never be captured if the
AutoEventWireup is set to false, or is there a way for the
AutoEventWireup to be set to false and for the Page_Load event to still
be captured?
Yes, manually hook up the handler method with the event:
Sub Page_Load (..., ...) Handles MyBase.Load
...
End Sub
(OR)
' Have the following line in any method/event handler that runs before page
load event.
AddHandler Me.Load, AddressOf Page_Load
"Steve" wrote:

> Thank you so much for that. I spent more than 2 needless hours this
> morning getting frustrated over this. Thank you so much.
> So does that mean the Page_Load event can never be captured if the
> AutoEventWireup is set to false, or is there a way for the
> AutoEventWireup to be set to false and for the Page_Load event to still
> be captured?
>

0 comments:

Post a Comment