@model IEnumerable<jquerylivesearch.Models.tbl_student_detail>
<div class="container">
<div class="form-group">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-search"></i></span>
<input type="text" id="Search" placeholder="Search...." class="form-control" />
</div>
</div>
</div>
<table class=" table table-striped">
<thead>
<tr>
<th>Student Id</th>
<th>Student Name</th>
<th>Semester</th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr class="Search">
<td>@item.std_id</td>
<td>@item.std_name</td>
<td>@item.semester</td>
</tr>
}
</tbody>
</table>
<script src="~/Scripts/jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function () {
function Contains(text_one, text_two) {
if (text_one.indexOf(text_two) != -1)
return true;
}
$("#Search").keyup(function () {
var searchText = $("#Search").val().toLowerCase();
$(".Search").each(function () {
if (!Contains($(this).text().toLowerCase(), searchText)) {
$(this).hide();
}
else {
$(this).show();
}
});
});
});
</script>
CONTROLLER CODE:
public ActionResult Index()
{
studentEntities db = new studentEntities();
return View(db.tbl_student_detail.ToList());
}
Comments
Post a Comment