dotnet / dotnet/AspNetCore.Docs

Please provide more information about the usage of the for attribute in a partial view

Open
#33,144 0 comments 0 reactions 1 assignee Claimed by @wadepickett View on GitHub
aspnet-core/svc mvc/subsvc okr-health Source - Docs.ms
Dominant language
C#
Stars
13.1k
Forks
24.6k
Avg merge
1d 3h
Merged PRs (30d)
97

Description

### Description

If you're using a Partial View with a nest model inside the main model, the controller method will receive an empty object because of the POST that prefix model properties with the main model name/type.

In this case, model should be used instead of for. this would say something like **model='Model.SubModelComplexObjectProperty'** instead of **for='SubModelComplexObjectProperty'**

### Page URL

https://learn.microsoft.com/en-us/aspnet/core/mvc/views/tag-helpers/built-in/partial-tag-helper?view=aspnetcore-8.0

### Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/mvc/views/tag-helpers/built-in/partial-tag-helper.md

### Document ID

e7df465a-5f3b-1522-b2d9-5e3afbf74257

### Article author

@Rick-Anderson

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.