Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

How to add a different layout (CSS, javascript) to a razor page in Blazor WASM?

$
0
0

I am working on a Blazor WASM e-commerce application using the .NET 6 old version with a default template. I want to add a new razor page with a different look while keeping the old ones in the project. How can I achieve this?Specifically, I want to add a new page with custom CSS and JavaScript, without affecting the existing pages. Can you guide me on how to do this step by step?

What I have done so far is, create an empty SampleLayout and add it under Shared folder beside the MainLayout.

@inherits LayoutComponentBase

I created a Test folder under Pages and added _Imports.razor having this inside of it.

@layout SampleLayout

Then added Home.razor page inside of the Test folder. Having page directive (@page "/Test/Home") and some markup with bootstrap. When I start the application and navigate to /Test/Home there is nothing displayed and no error as well.

I also added the required CSS and JavaScript files under wwwroot-css and -js folders. But I am not sure where to call them in the Home.razorpage.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>