473,320 Members | 2,162 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,320 software developers and data experts.

Page_Load not called

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

Jan 25 '07 #1
9 1632
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" <te*********@yahoo.comwrote in message
news:11*********************@s48g2000cws.googlegro ups.com...
>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
Jan 25 '07 #2

Thanks,

I tried that a few times.

jc

On Jan 25, 12:07 pm, "Cowboy \(Gregory A. Beamer\)"
<NoSpamMgbwo...@comcast.netNoSpamMwrote:
Compile first and see if that helps.

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

********************************************
Think outside the box!
********************************************"coltr ane" <tendenga...@yahoo.comwrote in messagenews:11*********************@s48g2000cws.go oglegroups.com...
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 -
Jan 25 '07 #3
>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.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load()
{
helloLbl.Text = "Hello, World";
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Page_Load Testing</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="helloLbl" runat="server" />
</div>
</form>
</body>
</html>
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujinionline.com
-----------------------------------------
Jan 26 '07 #4
On Jan 26, 4:02 am, "Gaurav Vaish \(MasterGaurav\)"
<gaurav.vaish.nos...@nospam.gmail.comwrote:
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.

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load()
{
helloLbl.Text = "Hello, World";}

</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
<title>Page_Load Testing</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="helloLbl" runat="server" />
</div>
</form>
</body>
</html>

--
Happy Hacking,
Gaurav Vaish |http://www.mastergaurav.comwww.eduji...jinionline.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

Jan 30 '07 #5
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
-----------------------------------------
Feb 1 '07 #6
On Jan 31, 9:33 pm, "MasterGaurav \(www.edujini-labs.com\)"
<gaurav.vaish.nos...@nospam.gmail.comwrote:
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 |http://www.mastergaurav.comwww.eduji...ujini-labs.com
-----------------------------------------
thanks

Feb 1 '07 #7
On Jan 31, 9:33 pm, "MasterGaurav \(www.edujini-labs.com\)"
<gaurav.vaish.nos...@nospam.gmail.comwrote:
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 |http://www.mastergaurav.comwww.eduji...ujini-labs.com
-----------------------------------------
Gaurav,

I have found that I must also remove the inherits directive also.

Feb 1 '07 #8
On Jan 31, 9:33 pm, "MasterGaurav \(www.edujini-labs.com\)"
<gaurav.vaish.nos...@nospam.gmail.comwrote:
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 |http://www.mastergaurav.comwww.eduji...ujini-labs.com
-----------------------------------------
me again, I figured it out. now I know about Web Forms page and
"single-file" web forms page

thanks again.

Feb 1 '07 #9
me again, I figured it out. now I know about Web Forms page and
"single-file" web forms page
Great!
Enjoy coding and happy hacking!
--
Happy Hacking,
Gaurav Vaish | www.mastergaurav.com
www.edujini-labs.com
http://eduzine.edujini-labs.com
-----------------------------------------
Feb 7 '07 #10

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

Similar topics

16
by: thejackofall | last post by:
Hi. I have a button called btnSelect on a web form. There is a handler for it. However, the Page_Load() gets called before the handler gets called. I want to do the following. In the...
13
by: z. f. | last post by:
Hi, i have a class that is derived from System.Web.UI.Page, and this is the class i use in my application as PageBase. all other page classes are deriverd from my PageBase instead of the...
5
by: Adam Clauss | last post by:
I have a webapp which consists of several different webforms. Basically: (1) view the contents of a database (2) one is to add a new entry (3) confirms the new entry. The third form, upon...
1
by: Jon | last post by:
Hi, I've set up a new web form (new.aspx) that inherits a BasePage class. The new web form contains an override Page_Load event. In BasePage, Page_Load is declared 'virtual'. In the new web...
2
by: magister | last post by:
Hello I have a default.aspx page with which has an iframe. In the code-behind of the default.aspx page it loads the 'src' attribute of the iframe. The iframe loads another aspx page, but...
6
by: Dot net work | last post by:
I've read quite a few threads on these groups about this. When someone says the following: "My Page_Load gets called twice on a button click postback" The replies are: "Do you have...
6
by: Olivier Matrot | last post by:
Hello, This has probably been asked several times, but It must be clarified for me. I would like to know why sometimes during a postback Page_Load is called after the function marked for...
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...
1
by: puja | last post by:
hi all, I have this .aspx page for which the Page_load event occurs twice. I found out while debugging. After searching google, I tried checking with Page.Ispostback method and also had...
11
by: fiefie.niles | last post by:
I am using ASP.NET 2005 and I have a simple form. Page_Load calls a sub mySub that does not do anything (for testing purposes). But, Page_Load gets called twice. On every single ASPX page in my...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.