@model IEnumerable<Eyepax.Test.Model.Test>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
@Html.DisplayNameFor(model => model.Name)
</th>
<th>
@Html.DisplayNameFor(model => model.Address)
</th>
<th>
@Html.DisplayNameFor(model => model.DepID)
</th>
<th>
@Html.DisplayNameFor(model => model.Donation)
</th>
<th>
@Html.DisplayNameFor(model => model.DepartmentName)
</th>
<th></th>
</tr>
@foreach (var item in Model)
{
if (item.Donation > 10000)
{
<tr>
<td style="background-color: green;">
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.DepID)
</td>
<td>
@Html.DisplayFor(modelItem => item.Donation)
</td>
<td>
@Html.DisplayFor(modelItem => item.DepartmentName)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
</td>
</tr>
}
else
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.Name)
</td>
<td>
@Html.DisplayFor(modelItem => item.Address)
</td>
<td>
@Html.DisplayFor(modelItem => item.DepID)
</td>
<td>
@Html.DisplayFor(modelItem => item.Donation)
</td>
<td>
@Html.DisplayFor(modelItem => item.DepartmentName)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id = item.ID }) |
@Html.ActionLink("Details", "Details", new { id = item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id = item.ID })
</td>
</tr>
}
}
</table>
<div>
<input id="txtSalary" style="width: 100px;" type="text" />
<select id="cmbType"></select>
<input id="btnSalary" type="button" value="Show Salary" />
</div>
<script type="text/javascript">
function LoadCombo() {
$.ajax({
type: 'POST',
url: '@Url.Action("GetStateList","TestStudent")', //call GetStudentDonations action on TestStudent controller
data: {
'countryCode': '', //parameters
},
success: function (result) {// calling function on return
$('#cmbType').empty();
$('#cmbType').append($('<option>', {
value: '', text: '-- Select --'
}));
for (var i = 0; i < result.length; i++) {
var obj = data[i];
var val = obj['Value'];
var text = obj['Text'];
$('#ddlState').append($('<option>', {
value: val,
text: text
}));
}
},
error: function () { // Unsuccess return
}
});
}
//Documnt ReADY EVENT/ FIRE WHEN HTML RENDERED
$(function () {
/// create the dropdown
LoadCombo(); // call LoadCombo
$("btnSalary").click(function () {
$.ajax({
type: 'POST',
url: '@Url.Action("GetStudentDonations","TestStudent")', //call GetStudentDonations action on TestStudent controller
data: {
'id': $("txtSalary").val(), //parameters
'loggedUsre': ''//parameters
},
success: function (result) {// calling function on return
if (result.Success)
alert('Selected student donation is : ' + result.Donation);
else
alert('Selected student donation not success');
},
error: function () { // Unsuccess return
}
});
});
})
</script>