Is there an equivalent "partial class" for aspx pages?

I have a very very long page, and to make html easier to read, I would like to split the pages into several subpages.

To manage my controls on the page, I already split my page with code in several files.

I would like to do the same with my aspx. What would I call this subpage and how would I start them? (for example, no <% @Page [...] ...>).

So far I have tried <!-- #Include virtual="~/path/page.aspx" --> with an empty aspx page (only "test" in aspx, no code).

It works, but then VS2010 throws me a bunch of errors (Too many characters in a literal literal.)

change

I would prefer not to use user controls:

I already use a lot of these. In this case, there is no need for reuse. These controls will also contain only other user controls. And I don’t want to disagree too much with the layout of all my other pages (which are shorter). Most pages have 3-4 controls, but this one has as much as 50. I would just like to split it into several html pages.

+4
source share
1 answer

I was close to the answer. It seems that the error caused by VS2010 on html went away after creating the project. However, I returned to creating code files for my subpage, although VS sorta got confused in all the files.

This is how I ended up splitting my page:

Parent aspx file:

 <!-- #Include virtual="~/Page/subPage.aspx" --> 

parent aspx.cs file:

 public partial class myPage 

Subpage aspx file:

Normal html (no @Page, @Imports, etc.), user controls ...

 <div style="margin:20px 0px;"> <asp:Panel runat="server" ID="table" /> </div> <CUSTOMCTRL runat="server" /> 

Aspx.cs Subpage File:

public partial class myPage

Aspx.designers.cs subpage file:

public partial class myPage

The only problem with this is the subpage developers: you need to manage them manually.

0
source

All Articles