Home How to divide a Certain Model into two parts in Razor View?
Reply: 1

How to divide a Certain Model into two parts in Razor View?

Abir Abrad
1#
Abir Abrad Published in 2017-12-07 04:26:55Z

I am using Articulate plugin in Umbraco for Blog Style and I need to show something default inside every Articulate Post. Here is what is happening now.

<section class="post-content">
   @Model.Body
</section>

And I need to do something below

<section class="post-content">
   @Model.Body.part1
   "Something Very Important"
   @Model.Body.part2
</section>

Thanks in advance.

Mario Lopez
2#
Mario Lopez Reply to 2017-12-08 05:36:49Z

Created two partial views and pass the same model to both. On each view just render the part you want.

<section class="post-content">
   @* the model will be passed to the partial view *@
   @Html.Partial("~/Views/Partial/PartialView1.cshtml"); 

   <p>Something very important here</p>

   @Html.Partial("~/Views/Partial/PartialView2.cshtml");
</section>

Then your partial views would be something like:

PartialView1.cshtml

<div>
   @Model.Body.part1
</div>

PartialView2.cshtml

<div>
   @Model.Body.part2
</div>

You don't really need the <div> but you get the point, right?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.262191 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO