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

Pass parameters from a Component to a Layout in Blazor Web App with (Server) Static Rendering Mode?

$
0
0

I'm using .NET 8 Blazor Web App with static rendering (and some part is WebAssembly Interactive but it's not relevant here I think). In MVC/Razor Pages, a page could pass variables (such as a bool) to the layout using ViewBag or similar mechanics, allowing the layout to conditionally show or hide parts of the UI, or in my case, add a class name to the <body> tag.

In Blazor, I tried to implement something similar to HeadContent/HeadOutlet by using a shared service, I even have an event and call StateHasChanged when the property is set but it's not reflected in the layout (I think it makes sense since the server does not care about it).

I know a workaround is to make many variations of the Layout but I am trying to avoid doing this. I don't think even generic Layout works (or am I wrong?).

Is it possible to pass certain info from the routed Component back to the Layout? I am fine if the values must be known at compile time.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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