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 152541
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:38:31+00:00 2026-05-11T09:38:31+00:00

in a noncompiled .aspx, is it possible to have 2 partial class files for

  • 0

in a noncompiled .aspx, is it possible to have 2 partial class files for one aspx? I’m trying to do something like:

     <%@ Page          Language='C#'          inherits='_Default'          src='Default.aspx.cs'          src='Default2.aspx.cs' %> 

Both Default and Default2 have the partial class defined

Update: Yep.. It’s not compiled or the point would be moot as I’d just chuck the corresponding dll’s in the /bin directory. I need to have this not compiled because the source needs to be changed regularly. I probably could come up with a way to just update the aspx, but I’d like to not have to do that.

The reason I’m using two source files is that there is a lot of source code that connects to my database and whatnot. I have one person that’s gonna muck with the db stuff and another person to muck with the other logic. I’d prefer to have these files separate so they don’t have to muddle through code that they don’t need to look at

  • 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. 2026-05-11T09:38:32+00:00Added an answer on May 11, 2026 at 9:38 am

    Yes and no. Yes, you can have as many partial classes as you wish. No, you cannot (nor do you have to!) specify them in your Page directive.

    <%@ Page          Language='C#'          inherits='Default' %> 

    in Default.aspx.cs:

    public partial class Default { /*yadda*/ } 

    in Default2.aspx.cs:

    public partial class Default { /* even more yadda */ } 

    Partial classes are an illusion of the compiler. They don’t exist as far as the CLR is concerned. The C# compiler stitches all the partial classes together during compilation; from the viewpoint of the asp.net compiler there is only one Default class.


    Sounds like from your update that what you need is not multiple partial classes but to refactor your code. You should drop the idea of partial classes and go with dependency injection/inversion of control. Separate out your db logic and other areas of concern, define them using interfaces, and then, at runtime, inject the desired implementation of these ‘providers’ using a DI container framework.

    This separates out your code and gives your application much more flexibility, testability and ease of updating; much better than just splitting code into two or more files. DI is pretty simple to understand and implement, also. I’m using Unity for DI and love it. It took about a day to get up to speed on it.

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

Sidebar

Ask A Question

Stats

  • Questions 80k
  • Answers 80k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I'm unaware of any such standard. What you have so… May 11, 2026 at 4:22 pm
  • Editorial Team
    Editorial Team added an answer Tip 1: Ensure you have exactly the same $PATH in… May 11, 2026 at 4:22 pm
  • Editorial Team
    Editorial Team added an answer They live throughout the lifetime of the AppDomain. (For Windows… May 11, 2026 at 4:22 pm

Related Questions

Is there a possibility that I can put some of my code in non-compiled
In a C# (feel free to answer for other languages) loop, what's the difference
In a desktop application needing some serious re-factoring, I have several chunks of code
In a world where manual memory allocation and pointers still rule (Borland Delphi) I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.