1- Make action for crud in any controller.
public ActionResult CrudCustmor()
{
return View();
}
2- Add its view and insert the following code in it.
@model IVR.EF.CUSTOMER
@{
ViewBag.Title = "";
Layout = "~/Views/Shared/_Layout_Admin.cshtml";
}
<style>
.k-widget.k-tooltip-validation {
width: 340px;
}.locally-button-width {
width: 100px;
}
/*.hidden-inline-mobile{
padding-bottom:2px !important;
}*/
</style>
<link href="@Url.Content("~/Common/css/tcgrid.css")" rel="stylesheet" />
<div class="col-md-12 no-padding-margin">
<div class="box border blue">
<div class="box-title">
</div><div class="box-body">
@using (Html.BeginForm("CrudCustmor", "DeshBoard", FormMethod.Post, new { enctype = "multipart/form-data", id = "CrudCustmor", name = "CrudCustmor" }))
{
<div class="tabbable">
<ul class="nav nav-tabs">
<li class="active" id="deviceModuleMap"><a href="#box_tabDeviceModuleMap" data-toggle="tab"> <i class="kk-group-WaypointMapTab hidden-inline-mobile"></i><span> Device Information</span></a></li><li class="" id="note"><a href="#box_tabNote" data-toggle="tab"><i class="fa fa-pencil-square-o hidden-inline-mobile"></i><span> Notes</span></a></li>
</ul><div class="tab-content" @*style="margin-bottom:-12px"*@>
<!--Contact h-->
<div class="tab-pane fade active in" id="box_tabDeviceModuleMap"><div class="row">
<div class="col-md-12 margin-header-account">
<div class="box-index">
<fieldset class="normalfieldset-lowpadding-index">
<div class="row"><div class="col-md-12">
<i class="col-ivr-Pup-icn kk-group-WaypointMap fa-2x hidden-inline-mobile" style="margin-top:5px !important"></i>
<div class="col-ivr-tab-text">
Specify information for a particular device</div>
</div>
</div>
</fieldset>
</div>
</div>
</div>
<div class="row">
<div class="divide-10"></div>
<div class="col-md-12 ">
<div class="box-index">
<fieldset class="normalfieldset-lowpadding-index">
<div class="row"><div class="divide-10"></div>
<div class="row">
<div class="col-md-10 ">
<label class="col-md-2">FirstName:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.FirstName, new { @class = "form-control", })
@* <label id="lblCustomer" class="k-widget k-tooltip k-tooltip-validation k-invalid-msg field-validation-error" hidden="hidden">NodeName cannot be blank.</label>*@</div>
<div class="divide-10 visible-xs"></div>
<label class="col-md-2">LastName:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.LastName, new { @class = "form-control", })
</div>
<div class="divide-10 visible-xs"></div>
</div>
</div>
<div class="divide-10"></div>
<div class="row">
<div class="col-md-10 ">
<label class="col-md-2">
Company:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.Company, new { @class = "form-control", })
</div>
<div class="divide-10 visible-xs"></div>
<label class="col-md-2">
Device:
</label>
<div class="col-md-4 ">
@Html.TextBoxFor(m => m.FirstName, new { @class = "form-control", })</div>
</div>
</div>
<div class="divide-10"></div>
<div class="row">
<div class="col-md-10 ">
<label class="col-md-2">
Address:
</label>
<div class="col-md-4 ">
@Html.TextBoxFor(m => m.Address, new { @class = "form-control", })
@* @Html.TextBoxFor(m => m.DestinationDeviceId, new { @class = "form-control", id = "compny" })*@
</div>
<div class="divide-10 visible-xs"></div>
<label class="col-md-2">
City:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.City, new { @class = "form-control", })@* @Html.TextBoxFor(m => m.Port, new { @class = "form-control" })*@
</div>
</div>
</div><div class="divide-10"></div>
<div class="row">
<div class="col-md-10">
<label class="col-md-2">
Country:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.Country, new { @class = "form-control", })</div>
<div class="divide-10 visible-xs"></div>
<label class="col-md-2">
LocalPhone:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.LocalPhone, new { @class = "form-control", })</div>
</div>
</div>
<div class="divide-10"></div>
<div class="row">
<div class="col-md-10">
<label class="col-md-2">
EMail:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.EMail, new { @class = "form-control", })
</div>
<div class="divide-10 visible-xs"></div></div>
</div><div class="divide-10"></div>
<div class="row">
<div class="col-md-10">
<label class="col-md-2">
DateOfBirth:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.DateOfBirth, new { @class = "form-control", })</div>
<div class="divide-10 visible-xs"></div>
<label class="col-md-2">
LoginName:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.LoginName, new { @class = "form-control", })</div>
</div>
</div><div class="divide-10"></div>
<div class="row">
<div class="col-md-10">
<label class="col-md-2">
Country:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.Country, new { @class = "form-control", })</div>
<div class="divide-10 visible-xs"></div>
<label class="col-md-2">
LoginPassword:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.LoginPassword, new { @class = "form-control", })</div>
</div>
</div><div class="divide-10"></div>
<div class="row">
<div class="col-md-10">
<label class="col-md-2">
Notes:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.Notes, new { @class = "form-control", })</div>
<div class="divide-10 visible-xs"></div>
<label class="col-md-2">
User1:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.User1, new { @class = "form-control", })</div>
</div>
</div>
<div class="divide-10"></div><div class="row">
<div class="col-md-10">
<label class="col-md-2">
User2:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.User2, new { @class = "form-control", })</div>
<div class="divide-10 visible-xs"></div>
<label class="col-md-2">
User3:
</label>
<div class="col-md-4">
@Html.TextBoxFor(m => m.User3, new { @class = "form-control", })</div>
</div>
</div>
</div>
</fieldset>
</div>
</div>
</div></div>
</div>
</div>
@*<div class="divide-10"></div>*@
<div class="divide-10"></div>
<div class="col-md-12 btn-Ivr-Ok-Cancel">
<button type="submit" value="OK" class="btn btn-default btn-width">OK</button>
<button type="button" id="CancelDeviceModuleMap" name="CancelDeviceModuleMap" value="OK" class="btn btn-default btn-width">Cancel</button></div>
}
</div>
</div>
</div>
3- Add another httppost action to accept the form when it will be submitted.
[HttpPost]
public ActionResult CrudCustmor(Customer model)
{
_db.Customers.Add(model);
_db.SaveChanges();
return View();
}