How I can Load another Razor Component into a Razor Component by a Button-click?
Asked Answered
I

1

7

I just want to load a razor component into another razor component when user click search button then I want to show search razor component (page) into a hidden div when the user click hide button then it will be hidden. like inline popup.

Innsbruck answered 31/1, 2020 at 18:41 Comment(0)
P
7

Like this:

Main Component:

@page "/test"


<button @onclick="(() => ShowComponent = true)">Show</button>
<button @onclick="(() => ShowComponent = false)">Hide</button>
@if (ShowComponent)
{
    <ShowHideComponent></ShowHideComponent>
}


@code {
    bool ShowComponent { get; set; } = false;
}

ShowHideComponent.razor:

<div>Show Or Hide This</div>
Pulitzer answered 31/1, 2020 at 18:54 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.