Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Blazor - EditForm not updating variables with bind-Value?

$
0
0

I'm pretty new to Blazor and I'm working on this little webapp which just logs form data into a JSON file (code below). However, the values for tmp.Cname and Cdate remain null when I submit the EditForm. Did I not use Model or bind-Value correctly? Thanks!!

@using System.Text.Json;@page "/"@code {    LogObject tmp = new LogObject();    public class LogObject{        public string Date {get; set;}        public string CDate {get; set;}        public string CName {get; set;}    }    public void OnSubmit(){        Console.WriteLine(tmp.CName +" at " + tmp.CDate);    }}<PageTitle>Home</PageTitle><h1>Hello, world!</h1><EditForm Model="tmp" OnSubmit = "OnSubmit" FormName="sample"><InputText @bind-Value="tmp.CName" /><br /><InputText @bind-Value="tmp.CDate" /><br /><button type="submit">Submit</button></EditForm><p>@tmp.CName changed at @tmp.CDate logged at @tmp.Date</p>

Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>