get unobtrusive validation html attributes by ViewModelType and property name
See original GitHub issueI need to get the unobtrusive validation html attributes (data-val-required=“msg”, data-val-length, etc.)
Ideally there would be a method like this:
IDictionary<string, string> dict = GetUnobtrusiveValidationAttributes<TViewModel>(propName);
I would call this inside an html helper (IHtmlHelper
extension method)
this issue is similar this one for MVC5 here https://github.com/aspnet/AspNetWebStack/issues/296 where I was able to find a solution, not perfect but it works.
so is this possible in ASP.net Core ?
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
get unobtrusive validation attributes by ViewModel Type
I tried doing: var html2 = new HtmlHelper<TModel>(html.ViewContext, html.ViewDataContainer) and using html2 instead of html but it won't help.
Read more >Unobtrusive Validation - ASP.NET MVC Demystified
Unobtrusive Validation allows us to take the already-existing validation attributes and use them client-side to make our user experience that ...
Read more >Model validation in ASP.NET Core MVC and Razor Pages
Validation attributes let you specify validation rules for model properties. The following example from the sample app shows a model class ...
Read more >Tag Helpers in forms in ASP.NET Core
The Input Tag Helper · Generates the id and name HTML attributes for the expression name specified in the asp-for attribute. · Sets...
Read more >MVC ValidationAttribute ErrorMessage populated at runtime
I am working on a project using EPiServer 7 and MVC 4. One of the nice features in MVC is ValidationAttributes in the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Something like:
Note that I wrote this in notepad, so I’m not entirely sure it compiles
This issue has been resolved and has not had any activity for 1 day. It will be closed for housekeeping purposes.
See our Issue Management Policies for more information.