Page_Load not called

Discussion in 'ASP .Net' started by coltrane, Jan 25, 2007.

  1. coltrane

    coltrane Guest

    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" language="C#">
    void Page_Load(){
    Message.Text = "This is a message";
    }
    </script>

    <body>
    <asp:Label ID="Message" Runat="server" />
    </body>


    This seems pretty basic. What might be the problem?

    thanks for the help

    jc
     
    coltrane, Jan 25, 2007
    #1
    1. Advertising

  2. Compile first and see if that helps.

    --
    Gregory A. Beamer
    MVP; MCP: +I, SE, SD, DBA
    http://gregorybeamer.spaces.live.com

    ********************************************
    Think outside the box!
    ********************************************
    "coltrane" <> wrote in message
    news:...
    >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" language="C#">
    > void Page_Load(){
    > Message.Text = "This is a message";
    > }
    > </script>
    >
    > <body>
    > <asp:Label ID="Message" Runat="server" />
    > </body>
    >
    >
    > This seems pretty basic. What might be the problem?
    >
    > thanks for the help
    >
    > jc
    >
     
    Cowboy \(Gregory A. Beamer\), Jan 25, 2007
    #2
    1. Advertising

  3. coltrane

    coltrane Guest

    Thanks,

    I tried that a few times.

    jc

    On Jan 25, 12:07 pm, "Cowboy \(Gregory A. Beamer\)"
    <> wrote:
    > Compile first and see if that helps.
    >
    > --
    > Gregory A. Beamer
    > MVP; MCP: +I, SE, SD, DBAhttp://gregorybeamer.spaces.live.com
    >
    > ********************************************
    > Think outside the box!
    > ********************************************"coltrane" <> wrote in messagenews:...
    >
    >
    >
    > >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" language="C#">
    > > void Page_Load(){
    > > Message.Text = "This is a message";
    > > }
    > > </script>

    >
    > > <body>
    > > <asp:Label ID="Message" Runat="server" />
    > > </body>

    >
    > > This seems pretty basic. What might be the problem?

    >
    > > thanks for the help

    >
    > > jc- Hide quoted text -- Show quoted text -
     
    coltrane, Jan 25, 2007
    #3
  4. >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" language="C#">
    > void Page_Load(){
    > Message.Text = "This is a message";
    > }
    > </script>


    Do you have you any codebehind / codebeside?
    Look into the @Page directive...

    btw, what is the output that you get?
    Can you explain what do you mean when you say "that just sets a variable"?

    I just tried with the code below and it works perfectly fine.

    --
    Happy Hacking,
    Gaurav Vaish | www.mastergaurav.com
    www.edujini-labs.com
    http://eduzine.edujinionline.com
    -----------------------------------------
     
    Gaurav Vaish \(MasterGaurav\), Jan 26, 2007
    #4
  5. coltrane

    coltrane Guest

    On Jan 26, 4:02 am, "Gaurav Vaish \(MasterGaurav\)"
    <> wrote:
    > >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" language="C#">
    > > void Page_Load(){
    > > Message.Text = "This is a message";
    > > }
    > > </script>

    >
    > Do you have you any codebehind / codebeside?
    > Look into the @Page directive...
    >
    > btw, what is the output that you get?
    > Can you explain what do you mean when you say "that just sets a variable"?
    >
    > I just tried with the code below and it works perfectly fine.
    >
    >
    >
    > --
    > Happy Hacking,
    > Gaurav Vaish |www.mastergaurav.comwww.edujini-labs.comhttp://eduzine.edujinionline.com
    > -----------------------------------------


    Gaurav,

    thank you for your reply.

    I used the following for my page:

    >>

    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
    AutoEventWireup="false" Inherits="Test.WebForm1" %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
    <script runat="server" language="C#">
    void Page_Load(){
    Message.Text = "this is a message ";
    }
    </script>
    <HTML>
    <HEAD>
    <title>WebForm1</title>
    <meta name="GENERATOR" Content="Microsoft Visual Studio .NET
    7.1">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name="vs_defaultClientScript" content="JavaScript">
    <meta name="vs_targetSchema" content="http://
    schemas.microsoft.com/intellisense/ie5">
    </HEAD>
    <body>
    <asp:Label ID="Message" Runat="server" />
    </body>
    </HTML>
    >>


    I found that if I changed the first line:
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
    AutoEventWireup="false" Inherits="Test.WebForm1" %>
    to
    <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" %>

    the message "This is a Message" is displayed.
    Now I have to find out why this occurs.

    thanks again

    john
     
    coltrane, Jan 30, 2007
    #5
  6. > I found that if I changed the first line:
    > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
    > AutoEventWireup="false" Inherits="Test.WebForm1" %>
    > to
    > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" %>



    "AutoEventWireup" is the culprit.
    Look into the documentation of "@ Page" directive and you'll get all answers
    to the mystery.

    I'll probably put this in my FAQ. I've seen this mistake done several times
    :)


    --
    Happy Hacking,
    Gaurav Vaish | www.mastergaurav.com
    www.edujini-labs.com
    http://eduzine.edujini-labs.com
    -----------------------------------------
     
    MasterGaurav \(www.edujini-labs.com\), Feb 1, 2007
    #6
  7. coltrane

    coltrane Guest

    On Jan 31, 9:33 pm, "MasterGaurav \(www.edujini-labs.com\)"
    <> wrote:
    > > I found that if I changed the first line:
    > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
    > > AutoEventWireup="false" Inherits="Test.WebForm1" %>
    > > to
    > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" %>

    >
    > "AutoEventWireup" is the culprit.
    > Look into the documentation of "@ Page" directive and you'll get all answers
    > to the mystery.
    >
    > I'll probably put this in my FAQ. I've seen this mistake done several times
    > :)
    >
    > --
    > Happy Hacking,
    > Gaurav Vaish |www.mastergaurav.comwww.edujini-labs.comhttp://eduzine.edujini-labs.com
    > -----------------------------------------


    thanks
     
    coltrane, Feb 1, 2007
    #7
  8. coltrane

    coltrane Guest

    On Jan 31, 9:33 pm, "MasterGaurav \(www.edujini-labs.com\)"
    <> wrote:
    > > I found that if I changed the first line:
    > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
    > > AutoEventWireup="false" Inherits="Test.WebForm1" %>
    > > to
    > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" %>

    >
    > "AutoEventWireup" is the culprit.
    > Look into the documentation of "@ Page" directive and you'll get all answers
    > to the mystery.
    >
    > I'll probably put this in my FAQ. I've seen this mistake done several times
    > :)
    >
    > --
    > Happy Hacking,
    > Gaurav Vaish |www.mastergaurav.comwww.edujini-labs.comhttp://eduzine.edujini-labs.com
    > -----------------------------------------


    Gaurav,

    I have found that I must also remove the inherits directive also.
     
    coltrane, Feb 1, 2007
    #8
  9. coltrane

    coltrane Guest

    On Jan 31, 9:33 pm, "MasterGaurav \(www.edujini-labs.com\)"
    <> wrote:
    > > I found that if I changed the first line:
    > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs"
    > > AutoEventWireup="false" Inherits="Test.WebForm1" %>
    > > to
    > > <%@ Page language="c#" Codebehind="WebForm1.aspx.cs" %>

    >
    > "AutoEventWireup" is the culprit.
    > Look into the documentation of "@ Page" directive and you'll get all answers
    > to the mystery.
    >
    > I'll probably put this in my FAQ. I've seen this mistake done several times
    > :)
    >
    > --
    > Happy Hacking,
    > Gaurav Vaish |www.mastergaurav.comwww.edujini-labs.comhttp://eduzine.edujini-labs.com
    > -----------------------------------------


    me again, I figured it out. now I know about Web Forms page and
    "single-file" web forms page

    thanks again.
     
    coltrane, Feb 1, 2007
    #9
  10. MasterGaurav \(www.edujini-labs.com\), Feb 7, 2007
    #10
    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?TkdN?=
    Replies:
    4
    Views:
    5,981
    piinfosoft
    Jul 12, 2012
  2. bminder
    Replies:
    1
    Views:
    2,212
    nfedin
    Feb 23, 2004
  3. Gustavo De la Espriella

    Page_Load not called when page is referenced again

    Gustavo De la Espriella, Aug 7, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    605
    Ashish M Bhonkiya
    Aug 8, 2004
  4. z. f.
    Replies:
    0
    Views:
    589
    z. f.
    Oct 19, 2004
  5. Andy
    Replies:
    5
    Views:
    6,430
Loading...

Share This Page