0

When i write :

   <% Html.EnableClientValidation(); %>
    <% using (Html.BeginForm())
    { %>
       <%: Html.ValidationSummary(false) %>
       <%: Html.EditorForModel() %>
       <p><input type="submit" name="name" value="Register" />   </p>
    <% } %>

My client validation works perfectly.

but when i change " <%: Html.EditorForModel() %>" with (all the code around is the same) :

   <div>User name<%: Html.EditorFor(x=>x.Name) %></div>
   <div>Password<%: Html.EditorFor(x=>x.Password)%></div>
   <div>Verify password <%: Html.EditorFor(x=>x.Password2) %></div>

Client side validation doesn't work.

am i missing something ? what "EditorForModel" does, that i didn't ?

1 Answer 1

2

Looks like you're missing validation messages. EditorForModel() is setting this up for you.

 @Html.ValidationMessageFor(x=>x.Name)
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks i thought it's a part of the "EditorFor"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.