Control Language Inherits System Web Mvc ViewUserControl Import Namesp

  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
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="ClothesRetail.Core" %>
<script src="<%= AppHelper.ScriptsUrl("MicrosoftAjax.js") %>" type="text/javascript"> </script>
<script src="<%= AppHelper.ScriptsUrl("jquery-1.3.2.js") %>" type="text/javascript"></script>
<script src="<%= AppHelper.ScriptsUrl("MicrosoftMvcAjax.js") %>" type="text/javascript"></script>
<%-- <script src="<%= AppHelper.ScriptsUrl("DDL_Creator.js") %>" type="text/javascript"></script> --%>
<script type="text/javascript">
// function CheckSelectedValue() {
// var categoryValue = $("#Categories").find(":selected").val();
// var brandValue = $("#Brands").find(":selected").val();
// if ((categoryValue == "" || categoryValue == "Select category") && (brandValue == "" || brandValue == "Select brand")) {
// return false;
// }
// return true;
//
// }
function SearchWithParams1() {
var categoryValue = $("#Categories").find(":selected").val();
var brandValue = $("#Brands").find(":selected").val();
if ((categoryValue == "" || categoryValue == "Select category") && (brandValue == "" || brandValue == "Select brand")) {
return;
}
else {
var clothTypesValue = $("#ClothTypes").find(":selected").val();
var sizesValue = $("#Sizes").find(":selected").val();
var colorsValue = $("#Colors").find(":selected").val();
//$.get('/Search/SearchWithParams', {}, null);
//Categories, string Brands, string ClothTypes, string Sizes, string Colors
$.ajax({
type: "GET",
url: '/Search/SearchWithParams',
data: ({ Categories: categoryValue, Brands: brandValue, ClothTypes: clothTypesValue, Sizes: sizesValue, Colors: colorsValue }),
async: true
});
}
}
</script>
<%-- <% using (Ajax.BeginForm("SearchWithParams", "Search", new AjaxOptions { HttpMethod = "get", UpdateTargetId = "main" }))
{ %>
<% using (Html.BeginForm("SearchWithParams", "Search", FormMethod.Get))
{%>--%>
<% using (Html.BeginForm())
{%>
<table>
<tr>
<td>
<label for="Categories">
Select category:</label>
</td>
<td>
<%--
esli sdelat ViewData["vvv"] : Cloth t; ViewData["vvv"] = new SelectList(_dataManager.Clothes.GetClothes(), "ClothId", "Name", t.ClothId);
to togda sozdat Html.DropDownList : <%= Html.DropDownList("StateId", (IEnumerable<SelectListItem>)ViewData["States"]) %>
--%>
<%= Html.DropDownList("Categories")%>
</td>
<td>
</td>
</tr>
<tr>
<td>
<label for="Brands">
Select brand:</label>
</td>
<td>
<%= Html.DropDownList("Brands")%>
<%--<select id="Vehicles" name="Vehicles"></select>--%>
</td>
<td>
</td>
</tr>
<tr>
<td>
<label for="ClothTypes">
Select type:</label>
</td>
<td>
<%= Html.DropDownList("ClothTypes", "Select type")%>
<%--<select id="Vehicles" name="Vehicles"></select>--%>
</td>
<td>
<%--<input type="submit" value="Search" id="SearchWithParams" onclick="return CheckSelectedValue();" />--%>
<input type="submit" value="Search" id="SearchWithParams" onclick="SearchWithParams1();" />
</td>
</tr>
<tr>
<td>
<label for="Sizes">
Select size:</label>
</td>
<td>
<%= Html.DropDownList("Sizes", "Select size")%>
<%--<select id="Sizes" name="Sizes" ></select>--%>
</td>
<td>
</td>
</tr>
<tr>
<td>
<label for="Colors">
Select color:</label>
</td>
<td>
<%= Html.DropDownList("Colors", "Select color")%>
<%--<select style= id="Colors" name="Colors"></select>--%>
</td>
<td>
</td>
</tr>
</table>
<% } %>
<% if (ViewData["NoResults"] != null || ViewData["SearchResults"] != null)
{ %>
<%} %>
<% if (ViewData["NoResults"] != null) %>
<%{ %>
<label id="noResults">
<%= (string)ViewData["NoResults"] %></label>
<%} %>
<% if (ViewData["SearchResults"] != null)%>
<% { %>
<div style="text-align: center">
<table>
<tr>
<td>
<%--<table>
<% foreach (ClothesRetail.Models.ClothCategory category in Model.SubCategories) %>
<% { %>
<tr>
<td>
<b><a href="/Cloth/RootCategory/<%=Model.Id%>?subcategory=<%=category.Id%>">
<%=category.Name%></a></b>
</td>
</tr>
<% } %>
</table>--%>
</td>
<td style="vertical-align: top">
<table>
<% ClothesRetail.Models.Cloth[] clothes = ViewData["SearchResults"] as ClothesRetail.Models.Cloth[];
for (int j = 0; j < (int)(clothes.Length / 3) + 1; j++)
{ %>
<tr>
<%
for (int i = 0; i < (j * 3 + 3 <= clothes.Length ? 3 : clothes.Length % 3); i++)
{
ClothesRetail.Models.Cloth cloth = clothes[i + j * 3];
%>
<td>
<table>
<tr>
<td class="thumbs">
<a href="/Cloth/Details/<%=cloth.Id%>" alt="/Cloth/Details/<%=cloth.Id%>" title="Click to Open">
<img src="<%=cloth.PhotoLink%>" alt="картинка" /></a>
</td>
</tr>
<tr>
<td>
<b><a href="/Cloth/Details/<%=cloth.Id%>">
<%=cloth.Name%></a></b>
</td>
</tr>
</table>
</td>
<% } %>
</tr>
<% } %>
</table>
</td>
</tr>
</table>
</div>
<%} %>