C# kode:
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 HelloWorld2
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Label1;
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
Label1.Text = "The date and time is " + DateTime.Now.ToString();
}
#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
}
}
.aspx kode (HTML):
<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="HelloWorld2.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>WebForm1</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"> </HEAD>
<body>
<form id="Form1" method="post" runat="server">
<P>
<DIV style="DISPLAY: inline; WIDTH: 176px; HEIGHT: 37px" ms_positioning="FlowLayout">
<H1>Hello World</H1>
</DIV>
</P>
<P>
<DIV style="DISPLAY: inline; WIDTH: 247px; HEIGHT: 24px" ms_positioning="FlowLayout">
<H1>ASP.NET Style</H1>
</DIV>
</P>
<P>
<DIV style="DISPLAY: inline; WIDTH: 276px; HEIGHT: 13px" ms_positioning="FlowLayout">
<H2>Using Visual Studio .NET</H2>
</DIV>
</P>
<P>
<asp:Label id="Label1" runat="server">Label</asp:Label></P>
</form>
</body>
</HTML>