Hi Rockstar8,
I have checked the code its working correctly.
Check this example. Now please take its reference and correct your code.
Model
public class OrderModel
{
public int Id { get; set; }
public string Name { get; set; }
public decimal? Sal { get; set; }
}
Controller
public class HomeController : Controller
{
// GET: /Home/
public ActionResult Index()
{
return View();
}
[HttpPost]
public JsonResult getsalarydetforfinyear(OrderModel det)
{
int id = det.Id;
string name = det.Name;
decimal? salary = det.Sal;
return Json(det);
}
}
View
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<_Decimal_Precision.Models.OrderModel>" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Index</title>
</head>
<body>
<div align="center">
<%using (Html.BeginForm("getsalarydetforfinyear", "Home", FormMethod.Post))
{%>
Id:
<%=Html.EditorFor(model => model.Id, new { htmlAttributes = new { @id = "Id", @autocomplete = "off" } })%>
<br />
Name:
<%=Html.EditorFor(model => model.Name, new { htmlAttributes = new { @id = "Name", @autocomplete = "off" } })%>
<br />
Salary:
<%=Html.EditorFor(model => model.Sal, new { htmlAttributes = new { @id = "Sal", @autocomplete = "off" } })%>
<br />
<br />
<input type="submit" class="btn btn-success" value="Save" id="btngasavesalarydet" />
<% } %>
</div>
</body>
</html>
Screenshot
The Form
Value in Controller