Call API function with HTMLActionLink

Here is a basic sample code

// In the controller add post method       
 [HttpPost]
        [ValidateAntiForgeryToken]
        public async Task<IActionResult> CalcLineAmount(int qty,int price)
        {
            SalesOrderLine line = (SalesOrderLine)TempData["lineedit"];
            line.LineAmount = qty * price;

            TempData["SalesOrderID"] = line.SalesOrderID;
            TempData["lineedit"] = line;

            return PartialView("~/Views/SalesOrders/_FormLine.cshtml", line);
        }


// call in chtml 
  @Html.ActionLink("Update", "CalcLineAmount", new { Model.Qty, Model.Price })

Leave a Reply

Your email address will not be published. Required fields are marked *