How to make use of Partial Class Files

Coreysan 1,631 Reputation points
2021-06-22T19:01:55.157+00:00

I hope this is simple! When I use Visual Studio, I can create separate files of the codebehind file (in my case, Default.aspx.cs)., all based on the "partial" keyword.
But when I set up everything in a typical IIS environment, I don't know how to get the aspx file to "see" those separate files.

Can this be done? If so, how do you do it?

Thank you in advance!

Internet Information Services
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,254 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Sam Wu-MSFT 7,036 Reputation points Microsoft Vendor
    2021-06-23T02:02:40.13+00:00

    Hi @Coreysan

    When you deploy .aspx pages, if their associated code-behind class files are precompiled, you only have to deploy the assembly to the Bin folder of the application. You do not have to deploy the actual code-behind class files with the application.

    When you deploy .aspx pages, if their associated code-behind class files are not precompiled, you must deploy the code-behind class files with the application. Additionally, you must add the Src attribute to the @ Page directive because the class file must be available when it is compiled on demand.

    More information about code-behind class file you can refer to this link: code-behind-class-files.


    If the answer is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Coreysan 1,631 Reputation points
    2021-06-25T16:42:13.347+00:00

    Yes - that's what I'm doing now. I wanted to know if I can separate them out, however.
    If it's a problem, or ASP.NET is not built for that as I've described, that would be helpful to know as well.

    Can it be done?