How do I take a subset of a views Model and send the subset model to a partial view?
I created a model, but the partial is looking for the parent model.
Am I creating this secondary subset model correctly? How do I get the partial to see this secondary subset model?
Parent View code (not all):
- @model GbngWebClient.Models.BlogPublishedByBlogIdVM
- @* Create a subset model to send to the partial view. *@
- @{
- int parentBlogId = @Model.BlogPublishedByBlogId.BlogId;
- int parentLikeCount = @Model.BlogPublishedByBlogId.LikeCount;
- int parentDisLikeCount = @Model.BlogPublishedByBlogId.DisLikeCount;
- bool parentDisabledBoolean =
- @Model.BlogPublishedByBlogId.DisabledBoolean;
- }
- class="row">class="col-md-1">
- @* A partial view. Sending the subset model to the partial view. *@
- @Html.Partial("_BlogLikeAndDislike", @Model)
Partial view code (not all):
- @* Get the parent view's values that were passed via a model. *@
- class="BlogLike fa fa-my-size fa-thumbs-up"> | @Model.LikeCount
- class="BlogDisLike fa fa-my-size fa-thumbs-down"> | @Model.DisLikeCount
First LastPosted Aug 19, 2020, 2:46 PM
class="blogLike my-size fa fa-thumbs-up">class="my-size"> : @Model.LikeCount class="my-size"> | class="blogDisLike my-size fa fa-thumbs-down">class="my-size"> : @Model.DisLikeCount
Laxmidhar SahooPosted Aug 19, 2020, 8:08 AM
Jishan SiddiquePosted Aug 19, 2020, 6:40 AM