Reputation: 1
I'have one page (Page1) that have 1 button and 1 textbox, when click on button I want to open a page that have a questionary, finish the questionary, the page is closed and I wanti to visualize in the text box (Page1) the result of the questionary. Thank.
Upvotes: 0
Views: 358
Reputation: 943
If I understand your question:
It seems that an Event will be your salvation. General idea could be
<h1>Parent</h1>
<p>@(ValueFromUser)</p>
<Child OnClose="OnCloseHandler"/>
@code {
private string ValueFromUser { get; set; } = default!;
private void OnCloseHandler(string value)
{
this.ValueFromUser = value;
}
}
And
<h1>Child</h1>
<input @bind="UserInput" />
<button @onclick="OnClick">Click here</button>
@code {
[Parameter] public EventCallback<string> OnClose { get; set; }
private string UserInput { get; set; } = default!;
private async Task OnClick()
{
await OnClose.InvokeAsync(UserInput);
}
}
Adding some CSS rules for the "page" to be closed.
Upvotes: 1