/
Search.cshtml
90 lines (88 loc) · 3.39 KB
/
Search.cshtml
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
@model SearchViewModel
@{
ViewBag.Title = "Search";
}
@section scripts
{
<script type="text/javascript">
$(function () {
$("#SortByField").change(function () {
$("#CurrentPage").val(0);
SubmitForm();
});
$("#PagingSize").change(function () {
$("#CurrentPage").val(0);
SubmitForm();
});
$("#Previous").click(function () {
var currentPage = $("#CurrentPage").val();
if (currentPage != null && currentPage > 0) {
currentPage--;
$("#CurrentPage").val(currentPage);
}
SubmitForm();
});
$("#Next").click(function () {
var currentPage = $("#CurrentPage").val();
if (currentPage) {
currentPage++;
$("#CurrentPage").val(currentPage);
}
SubmitForm();
});
});
function SubmitForm() {
document.forms["SearchForm"].submit();
}
</script>
}
@using (Html.BeginForm("Index", "Search", FormMethod.Post, new { id = "SearchForm" }))
{
<div class="SearchKeyword">
@Html.TextBoxFor(m => m.SearchKeyword, new {@class="SearchBox"})
<input id="Search" type="submit" value=" " class="SearchButton" />
</div>
<h2>Search Result</h2>
<div>
<div class="SearchHeader">
@Html.Hidden("CurrentPage", @Model.CurrentPage)
<div class="PagingContainer">
<span class="CurrentPage">Page @Model.CurrentPage of @Model.MaxPages</span>
<img id="Previous" src="@Url.Content("~/Content/Images/PagingPrevious.png")" class="PagingButton" />
<img id="Next" src="@Url.Content("~/Content/Images/PagingNext.png")" class="PagingButton" />
<div class="PageSize">
@Html.DropDownListFor(m => m.PagingSize, new SelectList(Model.PagingSizeList))
</div>
</div>
<div class="SortingContainer">
<span>Sort By:</span>
@Html.DropDownListFor(m => m.SortByField, new SelectList(Model.SortByFieldList))
</div>
</div>
<div class="SearchResultContainer">
<table>
@foreach (var item in @Model.SearchResult)
{
var auctionUrl = Url.Action("Auction", "Auctions", new { id = item.Key });
<tr>
<td class="searchDescription">
<div class="fieldContainer">
<a href="@auctionUrl">
<img src="@item.Image" title="@item.Title"/>
</a>
</div>
<div class="fieldContainer">
<div class="fieldTitle">@item.Title</div>
<div class="fieldDescription">
@item.Description
</div>
</div>
</td>
<td class="centered-field">@item.CurrentPrice</td>
<td class="centered-field">@item.RemainingTimeDisplay</td>
</tr>
}
</table>
</div>
</div>
}