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;
- }
-
- <div class="row">
- <div class="col-md-1">
- @* A partial view. Sending the subset model to the partial view. *@
- @Html.Partial("_BlogLikeAndDislike", @Model)
- </div>
- </div>
- <br />
Partial view code (not all):
- <div>
- @* Get the parent view's values that were passed via a model. *@
- <i class="BlogLike fa fa-my-size fa-thumbs-up"></i> | <i> @Model.LikeCount</i>
- <i class="BlogDisLike fa fa-my-size fa-thumbs-down"></i> | <i> @Model.DisLikeCount</i>
- </div>