Home > Mobile >  Blazor Server-App: Bind code behind to multiple Razor-components
Blazor Server-App: Bind code behind to multiple Razor-components

Time:07-11

I want to make a mobile desgin for my already existing blazor-server application I currently have my .razor files and the code behind in .razor.cs files.

What i want to do now is, to use 2 Front ends refering to the same Backend.

For Example

FooDesktop.razor -> Foo.razor.cs 
FooMobile.razor -> Foo.razor.cs

Is this possible? If no what are my alternatives.

CodePudding user response:

The solution I came up with goes like:

  1. Foo.razor.cs goes into a seperate class like FooComponent.cs
  2. FooMobile.razor and FooDesktop.razor now inherits this base class
  3. U can you all functionality of the base type inside your razor component
  • Related