Listing 1. ASPX page (WebForm1.aspx)

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="SampleWeb.WebForm1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
	<HEAD>
		<title>WebForm1</title>
		<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
		<meta content="C#" name="CODE_LANGUAGE">
		<meta content="JavaScript" name="vs_defaultClientScript">
		<meta content="http://schemas.microsoft.com/intellisense/ie5" name="vs_targetSchema">
	</HEAD>
	<body MS_POSITIONING="GridLayout">
		<form id="Form1" method="post" runat="server">
		<asp:button id="Button1" runat="server"Text="Button"></asp:button>
		<asp:label id="Label1" runat="server">Label</asp:label></form>
	</body>
</HTML>

Listing 2. CodeBehind page (Webform1.aspx.cs)

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 SampleWeb
{
	public class WebForm1 : System.Web.UI.Page
	{
		protected System.Web.UI.WebControls.Label Label1;
		protected System.Web.UI.WebControls.Button Button1;

		private void Page_Load(object sender, System.EventArgs e)
		{

		}

		#region Web Form Designer generated code
		override protected void OnInit(EventArgs e)
		{

			InitializeComponent();
			base.OnInit(e);
		}
		private void InitializeComponent()
		{
			this.Button1.Click += new System.EventHandler(this.Button1_Click);
			this.Load += new System.EventHandler(this.Page_Load);
		}
		#endregion

		private void Button1_Click(object sender, System.EventArgs e)
		{
			Label1.Text ="hello";
		}
	}
}

Listing 3. ASPX file in ASP.NET 2.0 (Default.aspx)

<%@ Page Language="C#" CompileWith="Default.aspx.cs" ClassName="Default_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" Runat="server" Text="Button" OnClick="Button1_Click" />
        <asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>

    </div>
    </form>
</body>
</html>

Listing 4. Code-behind file ASP.Net 2.0 (Default.aspx.cs)

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default_aspx
{
    void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text = "hello";
    }

}

Listing 5. Batch compiling setting in the Web.config of ASP.NET 1.X applications

<compilation
  batch="true|false"
  batchTimeout="number of seconds"
  maxBatchSize="maximum number of pages per batched compilation"
  maxBatchGeneratedFileSize="maximum combined size (in KB) of the
  generated source file per batched compilation"
</compilation>

Listing 6. The class inside the code folder (CodeClass.cs)

public class CodeClass
{

 public CodeClass()
{
}

public  static string GetLabelText()
{
	return "This Text is from the class";
}

}

Listing 7. The code-behind file using the class in the code folder (Default.aspx.cs)

using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Default_aspx
{
    void Button1_Click(object sender, EventArgs e)
    {
        Label1.Text =CodeClass.GetLabelText();
    }

}

Listing 8. The ASPX file (Default.aspx)

<%@ Page Language="C#" CompileWith="Default.aspx.cs" ClassName="Default_aspx" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" Runat="server" Text="Button" OnClick="Button1_Click" />
        <asp:Label ID="Label1" Runat="server" Text="Label"></asp:Label>
     </div>
    </form>
</body>
</html>

Listing 9. Possible code folder hierarchy

/Myweb
Default.aspx
	Default.aspx.cs
	/Code
		Common.cs
		/Customer
			Customer.cs


Listing 10. Implementing multiple compilation units in code folder

<compilation debug="false">
         <codeSubDirectories>
               <add directoryName="VB_Code" />
               <add directoryName="CS_Code" />
         </codeSubDirectories>
</compilation>