I put checkbox in .cshtml page with name attribute named "bSendEmail" to get the value as a boolean for further process. In post action method, I used a boolean parameter to get whether the checkbox is checked or not but I didn't get the value as true even the checkbox is checked. It always gives false.
I posted below what I am have tried
In .cshtml:
<form method="post" asp-action="ItemIndex">
<div class="row">
<div class="col-xl-12 text-center mt-3">
@if (g_EnableEmail == Constants.GeneralIndicator.Yes)
{
<input type="checkbox" id="chkSendMail" name="bSendEmail" class="my-checkbox" />
}
else
{
<input type="checkbox" id="chkSendMail" name="bSendEmail" class="my-checkbox" disabled />
<input type="hidden" name="bSendEmail" />
}
<label for="chkSendMail" class="head-label2">Send Email Notification</label>
</div>
</div>
<div class="row">
<div class="col-xl-12 text-center mt-10">
<button type="submit" asp-route-bConfirm="@false" asp-action="ItemIndex" class="genric-btn info circle"><i class="fa fa-check"></i> Save</button>
<button type="submit" asp-route-bConfirm="@true" asp-action="ItemIndex" class="genric-btn green circle"><i class="fa fa-check"></i> Finalize</button>
<a asp-controller="CreditNotes" asp-action="CreateEdit" asp-route-id="@Model.CreditNoteId" class="genric-btn danger circle "><i class="fa fa-times "></i> Cancel</a>
</div>
</div>
</form>
In Controller:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> ItemIndex(bool bConfirm, bool bSendEmail)
{
.... My codes are here
}
I couldn't get proper value from the parameter named "bSendEmail". Please help me to resolve this. Thanks in Advance
Aucun commentaire:
Enregistrer un commentaire