I have a post controller to which I want to pass value set with JS or JQuery. So in my JS file I'm trying this before submit:
function anullUser() {
$("#Mod").val("2");
$("#depForm").submit();
}
@{
@model IndexViewModel
}
<form id="depForm" class="formAddDepart" method="post">
<fieldset>
/.../
<input type="text" asp-for="Mod" />
</fieldset>
<div class="text-center">
<button class="btn btn-warning" onclick="anullUser()" type="button">JS FUNC CALL</button>
</div>
Controller code:
public IActionResult Users(IndexViewModel model)
{ if(model.Mod == 2) { /.../} else {/.../} }
But in my controller I'm still getting NULL value for this property. I even have tried to do it and set this field with AJAX and still.
UPDATE: asp-for attribute generates for me ID and NAME attributes.
