server-side model validation - error message in partial view
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 290
Description
### Describe the bug
Hello, I have a complex model object that I want to create a form for using tag helpers. I want to implement some parts of the form in partial views for nested object properties of the model.
```
public class Parent
{
[Required]
public string name { get; set; }
public Child child { get; set; }
}
public class Child
{
[Required]
public string description { get; set; }
}
```
```
@model Parent
Submit
```
```
@model Child
```
I use `name="child.description"` for the input to make model binding work correctly. I also added `data-valmsg-for="child.description"` to make the validation message to work correctly. All of these work fine when using jquery-validation and jquery-validation-unobtrusive. But when using server-side validation the validation messages for the partial view are not showing.
If I make partial view use the same model as main view and then use `asp-for="child.description"` and `asp-validation-for="child.description"`.
Is this a bug or am I missing something obvious here?
Kind regards, Dimitris.
### To Reproduce
Check the zip attachment for a minimalistic repro
[ValidationMessage.zip](https://github.com/dotnet/aspnetcore/files/5638843/ValidationMessage.zip)
Contributor guide
Assessment
This issue has not been assessed yet.