I am passing List from Model to view , so I specified in view like this IEnumerable. In this situation Client side validation is not firing
View :
@model IEnumerable<ShoppingCart.Models.ShoppingClass>
@{
ViewBag.Title = "Display";
}
<script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script>
@Html.ValidationSummary(true)
@using (Html.BeginForm())
{
<table>
<tr>
<td>@Html.Label("BrandName")
</td>
<td>@Html.TextBox("BrandName")
<div>
@Html.ValidationMessage("BrandName")</div>
</td>
<td>
<input type="submit" value="Search" name="Search" />
</td>
</tr>
</table>
}
What you've written is wrong.
You're got the view strongly typed but then you're not using the strongly typed properties or validation messages. Also, you've got the validation summary outside the form.. which won't work.
Then, you'll need to do something like this:
I'm not sure why you have a Search button for every item that goes to the same controller and action.. but I'll leave that for you to figure out.