C#.NET
C#.NET codefile (Web Forms)
SamplePage.aspx
<%@ Page Language="C#" CodeFile="SamplePage.aspx.cs" Inherits="SamplePage" AutoEventWireup="true" %>
<!DOCTYPE html>
<html lang="en">
<head runat="server">
<meta charset="UTF-8">
<title>C#.NET codefile</title>
</head>
<body>
<div>
<h2>Codefile example</h2>
<form id="form1" runat="server">
<asp:Label id="Label1" runat="server" Text="Label"></asp:Label>
<p>
<asp:Button id="Button1"
runat="server"
onclick="Button1_Click"
Text="Button">
</asp:Button>
</p>
</form>
</div>
</body>
</html>
SamplePage.aspx.cs
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class SamplePage : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Label1.Text = "Button clicked at " + DateTime.Now.ToString();
}
}