newbie - page load not firing

Discussion in 'ASP .Net' started by Steve, Nov 1, 2005.

  1. Steve

    Steve Guest

    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>
    &nbsp;</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?
    Steve, Nov 1, 2005
    #1
    1. Advertising

  2. Steve

    Jevon Guest

    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" <> wrote in message
    news:...
    > 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>
    > &nbsp;</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?
    >
    Jevon, Nov 1, 2005
    #2
    1. Advertising

  3. 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?
    >
    >
    =?Utf-8?B?U2l2YSBN?=, Nov 1, 2005
    #3
  4. Steve

    Steve Guest

    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?
    Steve, Nov 1, 2005
    #4
  5. 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?
    >
    >
    =?Utf-8?B?U2l2YSBN?=, Nov 1, 2005
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?Sko=?=

    Page Load Not Firing

    =?Utf-8?B?Sko=?=, Oct 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,734
    Scott Mitchell [MVP]
    Oct 20, 2004
  2. =?Utf-8?B?Sko=?=

    Page Load Not Firing

    =?Utf-8?B?Sko=?=, Oct 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    363
    =?Utf-8?B?Sm9lbCBDYWRl?=
    Oct 20, 2004
  3. venky

    Page Load and webcontrol page load

    venky, Jul 6, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    3,071
    venky
    Jul 11, 2005
  4. Dood
    Replies:
    1
    Views:
    610
  5. Slim
    Replies:
    0
    Views:
    298
Loading...

Share This Page