Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7698567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:16:21+00:00 2026-05-31T22:16:21+00:00

I have a .aspx Web Form with a .aspx.cs code-behind. The code-behind is nearly

  • 0

I have a .aspx Web Form with a .aspx.cs code-behind. The code-behind is nearly 2000 lines long, and it’s getting to the point where the only way to easily navigate it is to put a ton of spaces in between the sections, zoom out so I can see the physical look of the code, and then zoom in where I want to edit. In other words, it’s a major pain. I’d like to split this 2000 line into different files that represent concepts in the code. So when I need to go edit some functionality in the “Employee” jquery tab of the page, I can just go to the partial class that contains just the “Employee” functionality.

In the New Item menu, I cannot find anything for an additional code-behind file, no .aspx.cs file. I tried creating a .cs file, renaming it to .aspx.cs, and giving it the same partial class name — no go, I couldn’t see any of the methods of the default partial class, nor the controls on the page.

I understand the concept that if your “class”, in the OOP sense, is that long, it’s doing too much. What I don’t understand is a “class” in terms of code-behind for a web form. The form can’t really be broken down into smaller forms — the user experience needs to all take place on one page.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T22:16:22+00:00Added an answer on May 31, 2026 at 10:16 pm

    You could use partial classes. So add a new .cs file to your project and use a partial class.

    For example assuming you currently have the following Default.aspx.cs file:

    public partial class _Default : System.Web.UI.Page
    {
        ... some 2000 lines of code
    }
    

    you could add another .cs file to your project in which:

    public partial class _Default
    {
        ... a subset of the 2000 lines of code could be moved here
            in order to isolate some functionality
    }
    

    It’s very important that this partial class is declared in exactly the same namespace as the original class and has the same name.

    But note that using partial classes only hides the shit. It doesn’t clean it. If you want to clean it you will have to consider OOP practices to split functionality in different classes. You should layer your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very basic custom edit form, an aspx with code behind. It
I currently have a web form aspx page that calls RegisterClientScriptBlock. This sends down
Here is my issue. I have an ASPX web site and I have code
I have an asp.net web page. The code: <%@ Page Language=C# AutoEventWireup=true CodeBehind=Login.aspx.cs Inherits=Works.Login
I have a site a few years old that contains about 30 aspx Web
I have Default.aspx page, which inherits from BasePage.cs, which inherits from System.Web.UI.Page. BasePage is
I have an ASPX Page: <%@ Page Language=C# MasterPageFile=~/site.Master AutoEventWireup=true CodeBehind=Default.aspx.cs Inherits=myProject.Presentation.Web.Default src=Default.aspx.cs %>
I am new to web development. I have 2 .aspx files and in default
I have a web page (.aspx) that calls a third party web service to
I have an ASP.Net web site (ASPX and ASMX pages) with a single web.config

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.