Congratulations - C# Corner Q4, 2022 MVPs Announced
Why Join
Become a member
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
C# Corner Home
Technologies
Monthly Leaders
ASK A QUESTION
Forum guidelines
First Last
1.6k
613
45.9k
How to take a subset of a views Model and send the subset model
Aug 18 2020 3:56 PM
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>
Reply
Answers (
3
)
To integrate ebay, amazon product listing APIs in .net core 3.1
About checking Cookies on page load