<%@ 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>
<%} %>