I am starting with Blazor and I want add data to DB. But after filling InputTexts submit button not working (Not going to InsertUser).
Here is my code:
@page "/Users"@using DataAccessLibrary@using DataAccessLibrary.Models@using Models@inject IUserData _db@rendermode InteractiveServer<h3>Users</h3><h5>Insert new user</h5><EditForm FormName="Insert" Model=@newUser OnInvalidSubmit="@InsertUser"><DataAnnotationsValidator /><ValidationSummary /><div class="form-group"><InputText id="UserName" @bind-Value="newUser.UserName" class="form-control" /> <br /><InputText id="FullName" @bind-Value="newUser.FullName" class="form-control" /><br /><InputText id="Password" @bind-Value="newUser.Password" class="form-control" /></div><br /><input type="submit" class="btn btn-primary" value="Save" /></EditForm>@code{ private List<UserModel> user; public DisplayUserModel newUser = new DisplayUserModel(); protected override async Task OnInitializedAsync() { user = await _db.GetUsers(); } private async Task InsertUser() { UserModel us = new UserModel { UserName = newUser.UserName, Password = newUser.Password, FullName = newUser.FullName }; await _db.InsertUsers(us); user.Add(us); newUser = new DisplayUserModel(); }}Can you please help me....
I want to add new data to DB