Wednesday, 15 July 2015

asp.net mvc - display validation errors using @html.validationmessagefor -



asp.net mvc - display validation errors using @html.validationmessagefor -

i'm trying utilize @html.validationmessagefor() displaying errors in mvc, , i'm trying like: @html.validationmessagefor(@viewbag.price) syntax errors. want validation input:

input type="number" value="@viewbag.price" name="currentprice"

you're getting syntax errors because validationmessagefor takes in func. can't utilize @viewbag.price in , assume work. msdn definition of method is right here.

what need have method mapped specific field in model class (i.e. not viewbag) mvc knows exactly set validation message should 1 come after submission.

you instead utilize validationmessage, take field instead of func. illustration of using can found here.

asp.net-mvc model-view-controller asp.net-mvc-4 validation

No comments:

Post a Comment