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>
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" />
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