I have a form in a razor page where im implementing clientside validation using jquery, jquery unobtrusive and jquery validation alongside dataannotaions to validate the model.
Using strongly typed textboxes i get the data-val attributes that i need for displaying errors using ValidationMessage() method.
HOWEVER when i use the loosely typed textbox the data-val attributes does not get generated, why is this?
it is important that it works for Html.Textbox() since im using a more complex data structure and need to define specifik names for each element in the list.
loosly typed textbox and validationMessage:
Generated html:
Strongly typed textbox and validationMessage:
Generated html:
we can clearly see the data-val attributes here
The name field is built up like this (where key is a guid uniqe to each item in the list):
how come the data-val attributes don't appear with loosly typed textboxes?
I think i know the answer, since it is strongly typed we have information about the dataannotation in the model, whereas the loosley type just generates html from a name.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.