Yes, split up sub-sections of your code into System.Web.UI.UserControl
s (.ascx). You have to register a tag for your control with Default.aspx, and then you can include it just like you include <asp:
controls.
MyControl.ascx:
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="MyControl.ascx.cs" Inherits="MyControl" %>
<asp:Label ID="lblCoolLabel" runat="server" />
MyControl.ascx.cs:
public partial class MyControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
}
}
Default.aspx:
<!-- Registers your control -->
<%@ Register TagPrefix="controls" TagName="MyControl" Src="~/controls/MyControl.ascx" %>
<!-- Renders your control -->
<controls:MyControl ID="ucMyControl" runat="server" />