How to connect React.js forms with the properties of a C# model

32 Views Asked by At

I'm trying to do a C# and React application, and now I'm in the part where I would integrate both parts, I used some tutorials to help me setup and already did the insert in the controller class for example, that I'm already using ASP.NET Core MVC, for ControllerBase, but in the tutorial that I was relying on, the guy used tag helpers in a .cshtml file to make the form, while I wanted to use React.js, so I could handle the front end with, and only rely on C# to make the CRUD operations.

I wanted to integrate this:

lembreteModel.cs:

namespace PersonalReminders.Models
{
    public class LembreteModel
    {   
        public string? Descricao { get; set; }
        public DateTime Data {get; set; }
    }
}

With this form in react.js:

    return (
      <div className='telaInicial'>
        <h4>Novo lembrete</h4>
        <form>
          Lembrete:
          <input type='text' name='descricao' placeholder='digite o lembrete'></input>
          Data:
          <input type='date' name='data' placeholder='digite a data do lembrete. '></input>
          <button>Criar lembrete</button>
        </form>
        <h4>lista de Lembretes</h4>        
      </div>
    );

Any ideas of how to proceed?

0

There are 0 best solutions below