I am building a blazor app (WASM) where I use some <input>'s with those inputs. to both I binded a variable, for easy overview I put that in the @code part of the (index)page.
on the second <input> I also put an onclick event, and in the onclick event I fill a third variable (ThirdText) with the first (FirstText).
When I start the application, and I click on the first <input>, and fill in some characters and then click on the second <input> the value of the third variable is still empty. But when I go back to the first, change a bit, and click on the second afterwards, it directly fills the NEW value.
The last bahaviour is what I also hoped for in the first situation.
Here I have my code in index.cs:
@page "/"
<h3>@FirstText</h3> <br/>
<h3>@SecondText</h3> <br/>
<h3>@ThirdText</h3> <br/>
<input @bind="FirstText" style="width:50%" /> <br/>
<input @bind="SecondText" @onclick="OnclickHandler" style="width:50%" /> <br/>
@code{
private string FirstText { get; set; } = string.Empty;
private string SecondText { get; set; } = string.Empty;
private string ThirdText { get; set; } = string.Empty;
void OnclickHandler(MouseEventArgs mouseEventArgs)
{
ThirdText = FirstText;
}
}
This code is an easy example, the real application has a lot more logic, but this is the base of my problem.
When I make the first box empty, and click on the second box, again it does not work as expected.
I already tried to first fill the 3th variable in oninitialised() , but then the first variable is also empty so, that does not work.
I know in javascript there is a simular problem, that is because the onclick is firstly called, and the onexit or other event you want to use on the exit of the first box is then forgotten. But in that case, it goes wrong al the time. I hope that blazor has a solution for this situation. Because it goes well in Blazor if the first input was already filled.
