4

I would like to wither add an additional CSS class or give an ID to my @Html.ValidationSummary() tag. I tried the new keyword like I would with other HTML Helpers but gives an anonymous type to string conversion error. Is this possible to do and if so how?

@Html.ValidationSummary(false, new { @id = "validationSummary" })
2
  • The default .validation-summary-errors class not enough? Commented Jun 15, 2016 at 17:43
  • @RosdiKasim That would be a global change, there are certain pages in my app that have a different look/feel to them then others so I need to change it to match those. Commented Jun 15, 2016 at 18:09

1 Answer 1

7

There is no method overload for Html.ValidationSummary that receives (Boolean, Object). There is one that receives (Boolean, String, Object) though.

You could try this:

@Html.ValidationSummary(false, "", new { @id = "validationSummary" })
Sign up to request clarification or add additional context in comments.

2 Comments

That gives conversion errors for each one. First is string to Bool, second is bool to string, then Anonymous type to string.
I mistook the order of the parameters, updated the answer, please try again and let me know.

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.