asp.net mvc 3 - How to display only one error message using Html.ValidationSummary? -



asp.net mvc 3 - How to display only one error message using Html.ValidationSummary? -

i have view (skipping redundant code simplicity):

@model competencymodel @using (html.beginform()) { @html.validationsummary() @html.editorfor(model => model.results) }

when submit, if validation fails within editorfor, validationsummary shows list of validation messages each item coming editorfor.

this screenshot view, editorfor single line radio buttons:

but need single error message saying failed. tried:

@html.validationsummary(true) @html.editorfor(model => model.results)

but doesn't show anything. tried

@html.validationsummary(true) @html.editorfor(model => model.results) @html.validationmessagefor(model => model.results, "error !!!")

but doesn't show anything.

what doing wrong? give thanks you.

solution trick.

<style>.validation-summary-errors ul { display: none; }</style> @html.validationsummary("can't save, must reply questions !!")

the validationextensions.validationsummary method homecoming un-ordered list of items.

another person asked question , take utilize jquery hide items: http://stackoverflow.com/a/10837702/1220302

another solution display first item in list using css's nth-child pseudo tag. of course of study dependent on browser version you're using though:

i think this:

.validation-summary-errors ul li:nth-child(-n+1) { display:none; }

asp.net-mvc-3 razor validation

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -