Anonymous     JavaScript     01 Feb 2013    
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<script>
$(".update").click(function () {
var id = [];
$(".id").each(function (index, value) {
id[index] = $(value).val();
});
var fname = [];
$(".fname").each(function (index, value) {
fname[index] = $(value).val();
});
var lname = [];
$(".lname").each(function (index, value) {
lname[index] = $(value).val();
});
var position = [];
$(".positon").each(function (index, value) {
position[index] = $(value).val();
});
var salary = [];
$(".salary").each(function (index, value) {
salary[index] = $(value).val();
});
var n = $(".update").index(this);
$.ajax({
type: "POST",
url: "Default.aspx/UpdateEm",
data: '{id:' + id[n] +
'fname:' + fname[n] +
'lname:' + lname[n] +
'position:' + position[n] +
'salary:' + salary[n] +
'}',
contentType: "application/json; charset=utf-8",
dataType: "json"
});
});
</script>
[System.Web.Services.WebMethod]
public static void UpdateEm(string id, string fname, string lname, string position, string salary)
{
var EmID = int.Parse(id);
var EmSalary = decimal.Parse(salary);
using (DataEmployeeDataContext context = new DataEmployeeDataContext())
{
context.spUpdEmployee(EmID, fname, lname, position, EmSalary);
}
}