SoftWare/ASP.net Core Blazor
[ASP.NET Blazor] <input> Text Element 값 가져오기 Bind 및 Event
학수씨
2020. 8. 23. 00:49
<input type="text" @bind="CurrentValue" />
@code {
private string CurrentValue = "test";
}
요로케만 해주면... CurrentValue 와 바인딩 되어 언제든지 가져다 쓸수 있따..
Chagne Event 를 사용하고싶으면 여러가지 방식이 있다..
일단 나는 람다 방식은 너무 싫어하는 사람중에 한명이라 람다 방식말고 기본방식으로
<input type="text" @bind="CurrentValue" @onkeypress="CurrentValue_OnKeypress" />
@code {
private string CurrentValue;
void CurrentValue_OnKeypress(KeyboardEventArgs e)
{
System.Diagnostics.Debug.WriteLine(CurrentValue);
}
}