- Home
- /
- Foundation
- /
- DMBPageBuilder
- /
- Using in C#
Using in C#
Move rendering logic out of views when it becomes structural or reusable.
Overview
PageBuilder can be used directly from C# code, not only from Razor views. This is useful when HTML generation must be encapsulated in reusable classes, framework code, services, or rendering infrastructure.
Using PageBuilder in C# makes it possible to centralize rendering behavior while preserving the same attribute system, style system, builder lifecycle, and page model used in Razor-based rendering.
Why render in C#
Rendering directly in C# is especially useful when:
Relationship with the rendering pipeline
Using builders in C# does not bypass the PageBuilder pipeline. Builders rendered in C# can still participate in the same page model as components rendered from Razor.
Same pipeline, different location
A builder created in C# can still register scripts, stylesheets, and other page-level dependencies through PageInformation while it renders. The page pipeline remains the same — only the location of the rendering logic changes.
Typical use cases
Why this matters
Once rendering logic moves into C#, it becomes easier to reuse, test, document, and evolve. This is one of the reasons PageBuilder works well as a foundation for larger rendering ecosystems. Instead of treating HTML generation as view-only logic, PageBuilder allows it to become part of the application architecture.
Recommended usage
Continue with Examples
See the rendering model applied to practical real-world scenarios.
Examples →