In MVC3, i created one register form. I created one model,,controller and view. This is my code:
[HttpGet]
public ActionResult Insert()
{
Models.Employees objEmpl = new Models.Employees();
return View(objEmpl);
}
[HttpPost]
[AcceptVerbs("Post")]
public ActionResult Insert(Models.Employees objs)
{
var v = new Models.test().InsertDl(objs);
return View();
}
The above is my controller
@model MvcVideo.Models.Employees
@{
ViewBag.Title = "Insert";
Layout = "~/Views/Shared/VideoLayout.cshtml";
}
<h2>Insert</h2>
@using(Html.BeginForm("Insert","Home",FormMethod.Post ))
{
<table>
<tr>
<td>
Employee Name
</td>
<td>
@Html.TextBox("Ename",@Model.Enames)
</td>
</tr>
<tr>
<td>
Department Id
</td>
<td>
@Html.TextBox("Departmentid",@Model.DepartId )
</td>
</tr>
<tr>
<td>
Email Id
</td>
<td>
@Html.TextBox("Emailid",@Model.EmailIds)
</td>
</tr>
<tr>
<td>
Address
</td>
<td>
@Html.TextBox("Address",@Model.Adress)
</td>
</tr>
<tr>
<td colspan="2" style="text-align:center;" >
<button title ="Ok" value="OK"></button>
</td>
</tr>
</table>
}
But the objs
object at public actionresult Insert(models.Empoyees objs)
action method parameter is showing null values. Imean Ename=Null
, Department=0
, Emailid=Null
and Address=null