VIEW MODEL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Web.Mvc;
namespace WebApplication1.Models
{
public class EMPVM1
{
public EMPVM1()
{
HOBBY = new List<SelectListItem>();
LINTEREST = new List<SelectListItem>();
LCOUNTRY = new List<SelectListItem>();
LSTATE = new List<SelectListItem>();
}
[Required(ErrorMessage ="Eid should not be
blank.")]
public int?
EID { get; set; }
[Required(ErrorMessage = "Name should
not be blank.")]
public string NAME
{ get; set;
}
[Required(ErrorMessage = "Address
should not be blank.")]
[DataType(DataType.MultilineText)]
public string ADDRESS
{ get; set;
}
[Required(ErrorMessage = "Password
should not be blank.")]
[DataType(DataType.Password)]
[StringLength(8,MinimumLength
=6,ErrorMessage ="Password length between 6 to 8 charecter
long.")]
[Remote("CheackPwd","Emps",ErrorMessage ="This password alredy exist.")]
public string PASSWORD
{ get; set;
}
[Required(ErrorMessage = "Confirm
password should not be blank.")]
[DataType(DataType.Password)]
[DisplayName("CONFIRM PASSWORD")]
[System.ComponentModel.DataAnnotations.Compare("PASSWORD",
ErrorMessage ="Password and confrim
password must be same.")]
public string CPASSWORD
{ get; set;
}
[Required(ErrorMessage = "Please
select a gender.")]
public string GENDER
{ get; set;
}
[Required(ErrorMessage = "Salary
should not be blank.")]
[Range(5000,500000,ErrorMessage ="Salary
range between from 5000 to 500000.")]
public decimal?
SALARY { get; set; }
[Required(ErrorMessage = "Email
should not be blank.")]
[RegularExpression(@"\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*",
ErrorMessage ="Invalid email.")]
public string EMAIL
{ get; set;
}
[Required(ErrorMessage = "DOJ should
not be blank.")]
public DateTime? DOJ { get; set; }
[Required(ErrorMessage ="Please select a
country.")]
[Coustomvalidation2(ErrorMessage ="Please
select a hobby.")]
public List<SelectListItem> HOBBY
{ get; set;
}
public List<SelectListItem> LINTEREST
{ get; set;
}
[Coustomvalidation3(ErrorMessage = "Please
select a interest.")]
public List<string>
INTEREST { get; set; }
[Required(ErrorMessage ="Please select a
country.")]
[DisplayName("COUNTRY")]
public int?
CID { get; set; }
public List<SelectListItem> LCOUNTRY
{ get; set;
}
[Required(ErrorMessage = "Please
select a state.")]
[DisplayName("STATE")]
public int?
SID { get; set; }
public List<SelectListItem> LSTATE { get; set; }
}
public class Coustomvalidation2 : ValidationAttribute
{
public override bool IsValid(object value)
{
if (value == null)
return false;
return ((List<SelectListItem>)value).Count(x
=> x.Selected == true) > 0;
}
}
public class Coustomvalidation3 : ValidationAttribute
{
public override bool IsValid(object value)
{
if (value
== null)
return false;
return ((List<string>)value).Count
> 0;
}
}
}
CONTROLLER :
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebApplication1.Models;
namespace WebApplication1.Controllers
{
public class EmpsController : Controller
{
// GET: Emps
public ActionResult Index()
{
using (Database1Entities obj = new Database1Entities())
{
return View(obj.EMPs.ToList());
}
}
public JsonResult Fillddl(int CID)
{
using (Database1Entities obj = new Database1Entities())
{
return Json(obj.STATEs.Where(m => m.CID
== CID).ToList(), JsonRequestBehavior.AllowGet);
}
}
public PartialViewResult Openpop()
{
EMPVM1 vm = new EMPVM1();
using (Database1Entities obj = new Database1Entities())
{
vm.HOBBY = obj.HOBBies.Select(x => new SelectListItem
{ Value = x.HID.ToString(), Text = x.HNAME, Selected = false }).ToList();
vm.LINTEREST = obj.INTERESTs.Select(x => new SelectListItem
{ Value = x.IID.ToString(), Text = x.INAMEE }).ToList();
vm.LCOUNTRY = obj.COUNTRies.Select(x => new SelectListItem
{ Value = x.CID.ToString(), Text = x.CNAME }).ToList();
vm.LSTATE = new List<SelectListItem>();
}
return PartialView("PVCreate1",
vm);
}
public JsonResult CheackPwd(string PASSWORD)
{
using (Database1Entities obj = new Database1Entities())
{
if (PASSWORD == null)
return Json(false,
JsonRequestBehavior.AllowGet);
return Json(!obj.EMPs.Any(x =>
x.PASSWORD.ToLower() == PASSWORD), JsonRequestBehavior.AllowGet);
}
}
public ActionResult Save(EMPVM1 vm)
{
using (Database1Entities obj = new Database1Entities())
{
EMP emp = new EMP();
emp.EID = vm.EID ?? 0;
emp.NAME = vm.NAME;
emp.ADDRESS = vm.ADDRESS;
emp.PASSWORD = vm.PASSWORD;
emp.GENDER = vm.GENDER;
emp.SALARY = vm.SALARY;
emp.EMAIL = vm.EMAIL;
emp.DOJ = vm.DOJ;
emp.CID = vm.CID;
emp.SID = vm.SID;
obj.Entry(emp).State = EntityState.Added;
obj.SaveChanges();
obj.HOBBYMAPs.AddRange(vm.HOBBY.Where(p => p.Selected == true).Select(x => new HOBBYMAP { EID = vm.EID, HID =
Convert.ToInt32(x.Value) }));
obj.SaveChanges();
obj.INTERESTMAPs.AddRange(vm.INTEREST.Select(x => new INTERESTMAP { EID = vm.EID, IID =
Convert.ToInt32(x) }).ToList());
obj.SaveChanges();
return RedirectToAction("Index");
}
}
public PartialViewResult Openpar(int EID)
{
EMPVM1
vm = new EMPVM1();
using (Database1Entities obj = new Database1Entities())
{
EMP emp = obj.EMPs.Find(EID);
vm.EID = emp.EID;
vm.NAME = emp.NAME;
vm.ADDRESS = emp.ADDRESS;
vm.GENDER = emp.GENDER;
vm.SALARY = emp.SALARY;
vm.EMAIL = emp.EMAIL;
vm.DOJ = vm.DOJ;
vm.CID = vm.CID;
vm.SID = vm.SID;
List<SelectListItem> lst = new List<SelectListItem>();
int mark;
foreach (HOBBY hb in obj.HOBBies)
{
mark = 0;
foreach (HOBBYMAP hm in obj.HOBBYMAPs.Where(m=>m.EID==EID))
{
if (hb.HID == hm.HID)
{
mark = 1;
break;
}
}
if (mark == 1)
lst.Add(new SelectListItem {
Value=hb.HID.ToString(), Text=hb.HNAME,Selected=true });
else
lst.Add(new SelectListItem
{ Value = hb.HID.ToString(), Text = hb.HNAME, Selected = false });
}
vm.HOBBY = lst;
List<SelectListItem> lst1 = new List<SelectListItem>();
foreach (INTEREST ints in obj.INTERESTs)
{
mark = 0;
foreach (INTERESTMAP im in obj.INTERESTMAPs.Where(p => p.EID ==
vm.EID))
{
if (ints.IID == im.IID)
{
mark = 1;
break;
}
}
if (mark == 1)
lst1.Add(new SelectListItem {
Value=ints.IID.ToString(), Text=ints.INAMEE, Selected=true });
else
lst1.Add(new SelectListItem { Value =
ints.IID.ToString(), Text = ints.INAMEE, Selected = false });
}
vm.LINTEREST = lst1;
vm.DOJ = emp.DOJ;
vm.CID = emp.CID;
vm.SID = emp.SID;
vm.LCOUNTRY = obj.COUNTRies.Select(x => new SelectListItem
{ Value = x.CID.ToString(), Text = x.CNAME }).ToList();
vm.LSTATE = obj.STATEs.Where(p=>p.CID==vm.CID).Select(x => new SelectListItem { Value =
x.SID.ToString(), Text = x.SNAME }).ToList();
}
return PartialView("PVEdit",
vm);
}
public ActionResult Edit(EMPVM1 vm)
{
ModelState.Remove("PASSWORD");
ModelState.Remove("CPASSWORD");
using (Database1Entities obj = new Database1Entities())
{
EMP emp = obj.EMPs.Find(vm.EID);
emp.NAME = vm.NAME;
emp.ADDRESS
= vm.ADDRESS;
emp.GENDER = vm.GENDER;
emp.SALARY = vm.SALARY;
emp.EMAIL = vm.EMAIL;
emp.DOJ = vm.DOJ;
emp.CID = vm.CID;
emp.SID = vm.SID;
obj.Entry(emp).State = EntityState.Modified;
obj.SaveChanges();
obj.HOBBYMAPs.RemoveRange(obj.HOBBYMAPs.Where(x => x.EID == vm.EID));
obj.SaveChanges();
obj.HOBBYMAPs.AddRange(vm.HOBBY.Where(p
=> p.Selected == true).Select(x
=> new HOBBYMAP { EID =
vm.EID, HID = Convert.ToInt32(x.Value) }));
obj.SaveChanges();
obj.INTERESTMAPs.RemoveRange(obj.INTERESTMAPs.Where(p => p.EID ==
vm.EID));
obj.SaveChanges();
obj.INTERESTMAPs.AddRange(vm.INTEREST.Select(x => new INTERESTMAP { EID = vm.EID, IID =
Convert.ToInt32(x) }).ToList());
obj.SaveChanges();
return RedirectToAction("Index");
}
}
public JsonResult Delete(int EID)
{
using (Database1Entities obj = new Database1Entities())
{
EMP emp = obj.EMPs.Find(EID);
obj.Entry(emp).State = EntityState.Deleted;
obj.SaveChanges();
return Json(true,
JsonRequestBehavior.AllowGet);
}
}
}
}
Index view
@model IEnumerable<WebApplication1.Models.EMP>
@{
ViewBag.Title
= "Index";
Layout
= null;
}
<br />
<p>
<input type="button" value="Add New" class="btn
btn-primary" id="btnadd" />
</p>
<table class="table" id="tb">
<thead>
<tr>
<th>
@Html.DisplayNameFor(model =>
model.EID)
</th>
<th>
@Html.DisplayNameFor(model =>
model.NAME)
</th>
<th>
@Html.DisplayNameFor(model =>
model.ADDRESS)
</th>
<th>
@Html.DisplayNameFor(model =>
model.PASSWORD)
</th>
<th>
@Html.DisplayNameFor(model =>
model.GENDER)
</th>
<th>
@Html.DisplayNameFor(model =>
model.CID)
</th>
<th>
@Html.DisplayNameFor(model =>
model.SID)
</th>
<th>
@Html.DisplayNameFor(model =>
model.SALARY)
</th>
<th>
@Html.DisplayNameFor(model =>
model.EMAIL)
</th>
<th>
@Html.DisplayNameFor(model =>
model.DOJ)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var
item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.EID)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.NAME)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.ADDRESS)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.PASSWORD)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.GENDER)
</td>
<td>
@Html.DisplayFor(modelItem => item.CID)
</td>
<td>
@Html.DisplayFor(modelItem => item.SID)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.SALARY)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.EMAIL)
</td>
<td>
@{
string s = string.Format("{0:dd-MMM-yy}", item.DOJ);
}
@s
</td>
<td>
<a class="edit">Edit</a> |
<a class="del">Delete</a>
</td>
</tr>
}
</tbody>
</table>
<div id="dmldv"></div>
<div id="delForm" style="display:none">
<h1>Do you want to delete it ?</h1>
</div>
<link href="~/Content/bootstrap.css" rel="stylesheet" />
<link href="~/Content/jquery-ui.css" rel="stylesheet" />
<link href="~/Content/jquery.dataTables.min.css" rel="stylesheet" />
<link href="~/Content/jquery.dataTables_themeroller.css" rel="stylesheet" />
<script src="~/Scripts/bootstrap.js"></script>
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/jquery-ui.js"></script>
<script src="~/Scripts/jquery.dataTables.min.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<script type="text/javascript">
var createMode = $("#dmldv").dialog({
autoOpen: false,
modal: true,
width: 600,
show: { effect: 'blind', speed:
1000 },
hide: { effect: 'blind', speed:
1000 },
title: "Add New"
});
var Delform = $("#delForm");
$(function () {
$('#tb').on("click", ".edit", function () {
$.ajax({
"url": "@Url.Action("Openpar", "Emps")",
type: 'Get',
datatype: 'json',
cache: false,
data: { EID: $(this).closest("tr").find("td:eq(0)").text()
},
success: function (data) {
createMode.dialog("open");
createMode.empty().append(data);
},
error: function (t) {
alert(t.responseText);
}
});
});
$('#tb').on("click", ".del", function () {
var id = $(this).closest("tr").find("td:first").text();
Delform.dialog({
autoOpen: false,
modal: true,
width: 550,
title: "Delete",
show: { effect: 'blind', speed:
1000 },
hide: { effect: 'blind', speed:
1000 },
buttons: {
Yes: function () {
$.ajax({
"url": "/Emps/Delete",
type: 'Get',
datatype: 'json',
cache: false,
data: { EID: id },
success: function (Data) {
Delform.dialog("close");
window.location.reload(true);
},
error: function (t) {
alert(t.responseText);
}
});
},
No: function () {
Delform.dialog("close");
}
}
});
Delform.dialog("open");
});
$('#btnadd').click(function () {
$.ajax({
"url": "/Emps/Openpop",
type: 'Get',
datatype: 'json',
cache: false,
success: function (data) {
createMode.dialog("open");
createMode.empty().append(data);
},
error: function (t) {
alert(t.responseText);
}
});
});
var table = $("#tb").DataTable({
"order": [[0, "asc"]],
"lengthMenu": [[2, 10, 25, 50, -1],
[2, 10, 25, 50, "All"]],
"scroller": true,
"orderClasses": false,
})
})
</script>
Create partial view :
@model WebApplication1.Models.EMPVM1
@using (Html.BeginForm("Save","Emps",FormMethod.Post))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.EID,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.EID, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model =>
model.EID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NAME,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.NAME, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model =>
model.NAME, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ADDRESS,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.ADDRESS, new {
htmlAttributes = new { @class
= "form-control" }
})
@Html.ValidationMessageFor(model =>
model.ADDRESS, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.PASSWORD,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.PASSWORD, new {
htmlAttributes = new { @class
= "form-control" }
})
@Html.ValidationMessageFor(model =>
model.PASSWORD, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model =>
model.CPASSWORD, htmlAttributes: new {
@class = "control-label
col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.CPASSWORD, new {
htmlAttributes = new { @class
= "form-control" }
})
@Html.ValidationMessageFor(model =>
model.CPASSWORD, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.GENDER,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.RadioButtonFor(model =>
model.GENDER, "Male", new { htmlAttributes = new { @class = "form-control" }
})Male
@Html.RadioButtonFor(model =>
model.GENDER, "Female", new { htmlAttributes = new { @class = "form-control" }
})Female
@Html.ValidationMessageFor(model =>
model.GENDER, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.HOBBY,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@{
for (int i
= 0; i < Model.HOBBY.Count; i++)
{
@Html.CheckBoxFor(x =>
Model.HOBBY[i].Selected)
@Html.DisplayFor(x =>
Model.HOBBY[i].Text)
@Html.HiddenFor(x =>
Model.HOBBY[i].Value)
@Html.HiddenFor(x =>
Model.HOBBY[i].Text)@:
}
}
@Html.ValidationMessageFor(model =>
model.HOBBY, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.SALARY,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.SALARY, new {
htmlAttributes = new { @class
= "form-control" }
})
@Html.ValidationMessageFor(model
=> model.SALARY, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.EMAIL,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.EMAIL, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model =>
model.EMAIL, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DOJ,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.DOJ, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model =>
model.DOJ, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.INTEREST,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.ListBoxFor(model =>
model.INTEREST, Model.LINTEREST, new {
@class = "form-control" })
@Html.ValidationMessageFor(model =>
model.INTEREST, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CID,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model =>
model.CID, Model.LCOUNTRY, "Select", new { @class = "form-control" })
@Html.ValidationMessageFor(model =>
model.CID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.SID,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model => model.SID,
Model.LSTATE, "Select", new { @class = "form-control" })
@Html.ValidationMessageFor(model =>
model.SID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2
col-md-10">
<input type="submit" value="Create" class="btn
btn-default" />
</div>
</div>
</div>
}
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/jquery-ui.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<script type="text/javascript">
$(function () {
$('#DOJ').datepicker();
$('#CID').change(function ()
{
$('#SID').empty();
$('#SID').append("<option>Select</option>");
$.ajax({
url: '/Emps/Fillddl',
data: { CID: $(this).val() },
success: function (data) {
$.each(data, function (i, v) {
$('#SID').append("<option value="+v.SID+">"+v.SNAME+"</option>");
});
}
});
});
});
</script>
Edit partial view :
@model WebApplication1.Models.EMPVM1
@using (Html.BeginForm("Edit", "Emps", FormMethod.Post))
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.EID,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.HiddenFor(m=>m.EID)
@Html.DisplayFor(model =>
model.EID, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model =>
model.EID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.NAME,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.NAME, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model =>
model.NAME, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.ADDRESS,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.ADDRESS, new {
htmlAttributes = new { @class
= "form-control" }
})
@Html.ValidationMessageFor(model =>
model.ADDRESS, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.GENDER,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.RadioButtonFor(model =>
model.GENDER, "Male", new { htmlAttributes = new { @class = "form-control" }
})Male
@Html.RadioButtonFor(model =>
model.GENDER, "Female", new { htmlAttributes = new { @class = "form-control" }
})Female
@Html.ValidationMessageFor(model =>
model.GENDER, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.HOBBY,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@{
for (int i
= 0; i < Model.HOBBY.Count; i++)
{
@Html.CheckBoxFor(x =>
Model.HOBBY[i].Selected)
@Html.DisplayFor(x =>
Model.HOBBY[i].Text)
@Html.HiddenFor(x =>
Model.HOBBY[i].Value)
@Html.HiddenFor(x =>
Model.HOBBY[i].Text)@:
}
}
@Html.ValidationMessageFor(model =>
model.HOBBY, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.SALARY,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.SALARY, new {
htmlAttributes = new { @class
= "form-control" }
})
@Html.ValidationMessageFor(model =>
model.SALARY, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.EMAIL,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.EMAIL, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model =>
model.EMAIL, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.DOJ,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model =>
model.DOJ, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model =>
model.DOJ, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.INTEREST,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.ListBoxFor(model =>
model.INTEREST, Model.LINTEREST, new {
@class = "form-control" })
@Html.ValidationMessageFor(model =>
model.INTEREST, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.CID,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model =>
model.CID, Model.LCOUNTRY, "Select", new { @class = "form-control" })
@Html.ValidationMessageFor(model =>
model.CID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(model => model.SID,
htmlAttributes: new { @class
= "control-label col-md-2" })
<div class="col-md-10">
@Html.DropDownListFor(model =>
model.SID, Model.LSTATE, "Select", new { @class = "form-control" })
@Html.ValidationMessageFor(model =>
model.SID, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2
col-md-10">
<input type="submit" value="Create" class="btn
btn-default" />
</div>
</div>
</div>
}
<script src="~/Scripts/jquery-1.10.2.js"></script>
<script src="~/Scripts/jquery-ui.js"></script>
<script src="~/Scripts/jquery.validate.js"></script>
<script src="~/Scripts/jquery.validate.unobtrusive.js"></script>
<script type="text/javascript">
$(function () {
//$("#PASSWORD").rules("remove", "required")
//$("#CPASSWORD").rules("remove", "required")
//$("#CPASSWORD").rules("add", "required")
$('#DOJ').datepicker();
$('#CID').change(function () {
$('#SID').empty();
$('#SID').append("<option>Select</option>");
$.ajax({
url: '/Emps/Fillddl',
data: { CID: $(this).val() },
success: function (data) {
$.each(data, function (i, v) {
$('#SID').append("<option value="+v.SID+">"+v.SNAME+"</option>");
});
}
});
});
});
</script>
|
No comments:
Post a Comment