Reputation: 17701
I have a got a requirement like i need to show validation summary on top of page for that i have done like this in my view
@model MvcSampleApplication.Models.CrossFieldValidation
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
@Html.ValidationSummary(true) // here I have mentioned that validation summary true
but its not showing all messages in bulleted list
@using (Html.BeginForm("PostValues", "CrossFieldsTxtboxes"))
{
<div class ="editor-field">
@Html.TextBoxFor(m => m.TxtCrossField)
@Html.ValidationMessageFor(m=>m.TxtCrossField)
</div>
<div class =".editor-field">
@Html.DropDownListFor(m=> m.SelectedValue , Model.Items)
@Html.ValidationMessageFor(m=>m.SelectedValue)
</div>
<div class ="editor-field">
@Html.TextBoxFor(m =>m.ShippingValue)
@Html.ValidationMessageFor(m=>m.ShippingValue)
</div>
<div class =".editor-field">
@Html.DropDownListFor(m=> m.SelectedShippingItemValue , Model.Items)
@Html.ValidationMessageFor(m=>m.SelectedShippingItemValue)
</div>
<div class ="editor-field">
@Html.TextBoxFor(m =>m.DeliverPrice)
@Html.ValidationMessageFor(m=>m.DeliverPrice)
</div>
<div class =".editor-field">
@Html.DropDownListFor(m=> m.SelectedDeliveredItem , Model.Items)
@Html.ValidationMessageFor(m=>m.SelectedDeliveredItem)
</div>
<div class=".editor-field">
<input id="PostValues" type="Submit" value="PostValues" />
</div>
}
at present i am able to show the error messages near to drop down list and textbox but i want it at the top of page for that purpose what changes do i need to do in my view would any one pls suggest any ideas .. Many thanks in advance....
Note : I am using razor view engine..
Upvotes: 0
Views: 449
Reputation: 15387
Add below code into your web.config
. It will work
<appSettings>
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
</appSettings>
Updated
@Html.ValidationSummary(false)
Upvotes: 1
Reputation: 589
Simply try to put all your @Html.ValidationMessageFor(m=>m.Items)
right below
@Html.ValidationSummary(true)
and put this code where you want it on the page.
Upvotes: 1