This is my code
view
Add New User
Employee Name @Html.TextBoxFor(x => x.Name, new { @class = "form-control" })
Employee Position@Html.TextBoxFor(x => x.Position, new { @class = "form-control" })
Employee Office@Html.TextBoxFor(x => x.Office, new { @class = "form-control" })
Employee Salary@Html.TextBoxFor(x => x.Salary, new { @class = "form-control" })
Save User
@*
Employee Name@Html.TextBoxFor(x => x.Name, new { @class = "form-control" })
New User List
| Employee Name | Employee Positio | Employee Office | Employee Salary |
|---|
Controller
[HttpPost]
public ActionResult AddUser(string Name, string Position, string Office, string Salary)
{
Employee emp=new Employee();
emp.Name = Name;
emp.Position = Position;
emp.Office = Office;
emp.Salary =Convert.ToInt32(Salary);
db.Employees.Add(emp);
db.SaveChanges();
return Json(emp, JsonRequestBehavior.AllowGet);
}
public ActionResult AddUser(string Name, string Position, string Office, string Salary)
{
Employee emp=new Employee();
emp.Name = Name;
emp.Position = Position;
emp.Office = Office;
emp.Salary =Convert.ToInt32(Salary);
db.Employees.Add(emp);
db.SaveChanges();
return Json(emp, JsonRequestBehavior.AllowGet);
}
Sanwar RanwaPosted Sep 3, 2018, 1:06 AM
Gaurav RajPosted Sep 3, 2018, 1:25 AM
Gaurav RajPosted Sep 3, 2018, 1:03 AM
Sanwar RanwaPosted Sep 3, 2018, 1:00 AM