Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi,
I have this page where information is loaded from umbraco with IPublishedContent:
@{ List<ContentBlok> blokken = new List<ContentBlok>(); var items = Model.GetPropertyValue<IEnumerable<IPublishedContent>>("blokken"); foreach (var item in items) { var blokTitel = item.GetPropertyValue("titel") != null ? item.GetPropertyValue("titel") : ""; var iscounterblock = item.GetPropertyValue("Verzoeken") != null ? item.GetPropertyValue("Verzoeken") : false; var isimportant = item.GetPropertyValue("Belangrijk") != null ? item.GetPropertyValue("Belangrijk") : false; var content = item.GetPropertyValue("Content") != null ? item.GetPropertyValue("Content") : new HtmlString("a"); ContentBlok blok = new ContentBlok { IsCounterBlock = (bool)iscounterblock, IsImportant = (bool)isimportant, Content = (HtmlString)content, Titel = (string)blokTitel }; blokken.Add(blok); } <div class="o-grid js-grid"> @foreach (var item in blokken) { @Html.Partial("PartialContentBlock", item); } </div>
But when I add an @model tag to the view I cannot access GetPropertyValue and the umbraco items anymore.
public ActionResult Index() { JavaScriptSerializer serializer = new JavaScriptSerializer(); User user = (User)serializer.Deserialize (((FormsIdentity)System.Web.HttpContext.Current.User.Identity) .Ticket.UserData, typeof(User)); HomeViewModel homeViewModel = new HomeViewModel { ShowPortaal = user.ShowPortaal, AllPerms = user.AllPerms }; return View("Home", homeViewModel); }
Is there a way to get both?
Solved with extending the Model with RenderModel.
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Acces to GetPropertyValue and having a ViewModel?
Hi,
I have this page where information is loaded from umbraco with IPublishedContent:
But when I add an @model tag to the view I cannot access GetPropertyValue and the umbraco items anymore.
Is there a way to get both?
Solved with extending the Model with RenderModel.
is working on a reply...