Class receiving zero value

0

I am doing insert via post, but my class is getting zero values and the values of the inputs are passed via variable and are displayed correctly, but at the moment of action via post are coming with zero values. p>

The most interesting thing is if you type inside the input, then the values come correctly.

<form method="post">
<div class="col-sm-3">
    <label>SALDO</label>
    <div style="border:1px solid #bbb9b9; border-radius:3px;"></div>
    <br />
    <div class="form-group">
        <label asp-for="Caixas.ValorFinalDinheiro" class="control-label"></label>
        <input asp-for="Caixas.ValorFinalDinheiro" name="Caixas.ValorFinalDinheiro" 
            id="Caixas.ValorFinalDinheiro" class="form-control finalFundo"  disabled="disabled" />
    </div>
    <div class="form-group">
        <label asp-for="Caixas.ValorFinalCheque" class="control-label"></label>
        <input asp-for="Caixas.ValorFinalCheque" class="form-control finalFundo"  disabled="disabled"/>

    </div>
    <div class="form-group">
        <label asp-for="Caixas.ValorFinalBoleto" class="control-label"></label>
        <input asp-for="Caixas.ValorFinalBoleto" class="form-control finalFundo"  disabled="disabled" />

    </div>
    <div class="form-group">
        <label asp-for="Caixas.ValorFinalCartao" class="control-label"></label>
        <input asp-for="Caixas.ValorFinalCartao" class="form-control finalFundo"  disabled="disabled" />

    </div>
    <div class="form-group">
        <label asp-for="Caixas.ValorFinalDeposito" class="control-label"></label>
        <input asp-for="Caixas.ValorFinalDeposito" class="form-control finalFundo" disabled="disabled"  />

    </div>
    <div class="form-group">
        <label asp-for="Caixas.ValorFinal" class="control-label"></label>
        <input asp-for="Caixas.ValorFinal" class="form-control" style="background-color:#9FF781"   />

    </div>
</div>
<div class="col-sm-12">
    <div class="form-group">
        <input type="submit" value="Confirmar o Fechamento do Caixa" class="btn btn-primary btn-sm"  />
        <a asp-page="Index" class="btn btn-success btn-sm">Retorna ao Caixa</a>
    </div>
</div>
</form>
[BindProperty]
public Caixas Caixas { get; set; }

public async Task<IActionResult> OnPostAsync()
{


    var C = _context.Caixas.Find(Caixas.Id);
    C.fechado = true;
    C.DataFinal = DateTime.Now;
    C.HoraFinal = DateTime.Now;

    C.FuncionarioFechamentoId = _userManager
        .GetUserId(HttpContext.User);

    C.ValorFinalDinheiro = Caixas.ValorFinalDinheiro;
    C.ValorFinalCheque = Caixas.ValorFinalCheque;
    C.ValorFinalBoleto = Caixas.ValorFinalBoleto;
    C.ValorFinalCartao = Caixas.ValorFinalCartao;
    C.ValorFinalDeposito = Caixas.ValorFinalDeposito;
    C.ValorFinal = Caixas.ValorFinal;

    C.ValorSaida = Caixas.ValorSaida;

    await _context.SaveChangesAsync();
    return RedirectToPage("./Index");
}
    
asked by anonymous 30.07.2018 / 13:46

1 answer

1

The problem was happening because the inputs were disabled.

In fact, all browsers do not send input values disabled.

As I needed to display the values, then I created other <input type="hidden"> and solved my problem.

Thank you.

    
30.07.2018 / 17:03