Layers is the one you needed. But if you don't know how to separate you code in the presentation and business layers then in your case you can use hierarchical pages.
For example
this is a class file in the app code. Put all the common codes here. what I shown is wrong, it is not good advice to put event handler here. Common business logic can go here. I just put an event handler here just to show the possibility.
public partial class BasePage : System.Web.UI.Page
{
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("button Clicked");
}
}
Now you can inherit your page from this class.
public partial class _Default : BasePage
{
protected void Page_Load(object sender, EventArgs e)
{
Button1.Click +=new EventHandler(Button1_Click);
}
}
Now the button click is in another file, but can be called from your page code. Instead of using event handlers like this, you can move the common function to a parent class and inherit the pages accordingly.