If you want ur <Script runat="Server"...> to work, you need to set
AutoEventWireUp to true in the @Page directive.
I don't think there's any good reason to use both inline code (<script
runat="server">...</script>) and codebehind (the MainWebForm.aspx.cs)
Decide which methodology you want to use and stick with it (I prefer the
codebehind, and so does Visual Studio .Net). Therefore, if you simply
removed ur <script runat="Server"... and put the MyTimeLabel.Text = "You
last accessed this page at: " + DateTime.Now in the Page_Load of the .cs
file and recompiled everything should work.
Karl
--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!
"Richard Lionheart" <> wrote in message
news:...
> Hi All,
>
> I adapted some sample code from w3schools.com and tried to adapt it to
> .NET to test dynamic processing in a WebForm. The client page that got
> generated produced everything that was coded except for displaying the
> time at which it was generated. I tried everything I could think of to
> rewrite this and to debug this.
>
> Anyone out there in Cyberspace got any idea why the time doesn't get
> displayed. The .aspx code follows below
>
> Thanks in Advance,
> Richard
>
> ======== MainWebForm.aspx ===============
> <%@ Page language="c#" Codebehind="MainWebForm.aspx.cs"
> AutoEventWireup="false" Inherits="TestDynamicTimeReporting2.WebForm1" %>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
> <HTML>
> <HEAD>
> <title>Dynamic-Time Form</title>
> <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
> <meta name="CODE_LANGUAGE" Content="C#">
> <meta name="vs_defaultClientScript" content="JavaScript">
> <meta name="vs_targetSchema"
> content="http://schemas.microsoft.com/intellisense/ie5">
>
> <script language="C#" runat="server">
> void Page_Load(Object Src, EventArgs E) {
> MyTimeLabel.Text = "You last accessed this page at: " +
> DateTime.Now;
> }
> </script>
>
> </HEAD>
> <body MS_POSITIONING="GridLayout">
> <form id="MyForm" method="post" runat="server">
> <asp:Label id="MyTopLabel" style="Z-INDEX: 101; LEFT: 160px;
> POSITION: absolute; TOP: 19px" runat="server" Width="429px" Height="25px">
> <h1>Test Dynamic Time Reporting</h1>
> </asp:Label>
> <asp:Label id="MyTimeLabel" style="Z-INDEX: 102; LEFT: 291px;
> POSITION: absolute; TOP: 102px" runat="server" Width="190px" Height="22px"
> ForeColor="Red">The time is ...........................</asp:Label>
> <asp:Button id="MyButton" style="Z-INDEX: 103; LEFT: 326px;
> POSITION: absolute; TOP: 198px" runat="server" Width="106px" Height="33px"
> Text="Update the time"></asp:Button>
> </form>
> </body>
> </HTML>
>
>
> =================== MainWebForm.aspx =========================
>
> using System;
> using System.Collections;
> using System.ComponentModel;
> using System.Data;
> using System.Drawing;
> using System.Web;
> using System.Web.SessionState;
> using System.Web.UI;
> using System.Web.UI.WebControls;
> using System.Web.UI.HtmlControls;
>
> namespace TestDynamicTimeReporting2
> {
> /// <summary>
> /// Summary description for MainWebForm.
> /// </summary>
> public class MainWebForm : System.Web.UI.Page
> {
> protected System.Web.UI.WebControls.Label MyTopLabel;
> protected System.Web.UI.WebControls.Label MyTimeLabel;
> protected System.Web.UI.WebControls.Button MyButton;
>
> private void Page_Load(object sender, System.EventArgs e)
> {
> // Put user code to initialize the page here
> }
>
> #region Web Form Designer generated code
> override protected void OnInit(EventArgs e)
> {
> //
> // CODEGEN: This call is required by the ASP.NET Web Form Designer.
> //
> InitializeComponent();
> base.OnInit(e);
> }
>
> /// <summary>
> /// Required method for Designer support - do not modify
> /// the contents of this method with the code editor.
> /// </summary>
> private void InitializeComponent()
> {
> this.Load += new System.EventHandler(this.Page_Load);
>
> }
> #endregion
> }
> }
>
>
>