티스토리 뷰

😀 .NET Core Blazor

@bind

James Wetzel 2024. 3. 21. 14:04
728x90
반응형

HTML element 정보를 @code(블록)으로 가져 오기

 

Data Binding

<input type="text" @bind="myInputValue" />

@code {
    private string myInputValue = "";

    private void HandleSubmit()
    {
        // Access myInputValue here
    }
}

 

Event Handling

<input type="text" @oninput="HandleInput" />

@code {
    private string inputValue = "";

    private void HandleInput(ChangeEventArgs e)
    {
        inputValue = e.Value.ToString();
        // Access inputValue here
    }
}
728x90
반응형