jeudi 4 avril 2019

Checkbox input remains false on form submit

I am trying to post a form and even though all the inputs map their value accordingly in the receiving controller-method , the bool-s of checkbox-es remain false. What am i doing wrong ?

POCO

class MyPoco
{ 
   public string User{get;set;}
   public bool Require {get;set;}
}

Form

<form id="createForm" method="post" action="[some url]">

<input type="checkbox" id="require" name="Require" />

<input type="text" id="user" name="User"/>

</form>

Controller (method)

 [HttpPost]
 [Route("[some url]")]
 public async Task<long> CreateAsync(MyPoco request)
 {

 }

Why in my case above does request.Require is always false.I have mapped them correctly (the name attribute).




Aucun commentaire:

Enregistrer un commentaire