Reputation: 11
My website has two concepts. One for electronics store and one for books store. The user can select the concept upon registering at my razor pages web application.
The selection is stored as an enum in the database.
public enum Layout
{
ElectronicsStore = 1,
BookStore,
}
The razor page check this one and renders different output.
@page
@model IndexModel
@{
ViewData["Title"] = "Home page";
}
@switch (Model.Layout)
{
case context.Layout.ElectronicsStore:
<body>
1
</body>
break;
case context.Layout.BookStore:
<body>
2
</body>
break;
}
What is the appropriate way of achieving this one? Should i use a partial view for that purpose? Keep in mind that the rendered view, will actually be the body of the whole page which actually is not a "partial view"
Upvotes: 1
Views: 34
Reputation: 18209
Keep in mind that the rendered view, will actually be the body of the whole page which actually is not a "partial view"
If you mean <body></body>
is the whole page code,I think using partial view will reduce much duplicate code in your page.So I think using partial view is better.
@switch (Model.Layout)
{
case context.Layout.ElectronicsStore:
<partial name="Partial" model=xxx />
break;
case context.Layout.BookStore:
<partial name="Partial" model=xxx />
break;
}
Upvotes: 1