I have the basic controller code :
public async Task<IActionResult> Index(StudentViewModel model,bool isOpen = true)
{
if (isOpen == false)
{
model.Open = false;
}
else
{
model.Open = true;
}
return View(model);
}
View :
<form id="frmStudent" method="post" asp-action="Index">
<input asp-for="Open " type='checkbox' />
</form>
Script :
$('#Open').change(function () {
var isOpen = true;
if (this.checked) {
isOpen = true;
}
else
{
isOpen = false;
}
if(isOpen == true)
{
//Call the Index method with isOpen = true and reload the page
}
else{
// Call the Index method with isOpen = false and reload the page.
}
}
So how do I go about reloading the entire page based on the condition in my script section? Is AJAX the only solution?
question from:
https://stackoverflow.com/questions/65940212/reload-page-based-on-checkbox-selection 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…