I need to pass in 2 objects to a page to access Model.NewsItems and Model.Links (the first is a class of news item objects with heading, content etc and the Links are a set of strings for hyperlink depending on whether the system is up or down.
This is the page declaration
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<Tolling.Models.NewsItems>" %>
If I refer to Model.Items
- I am fine.
However, if I refer to Model.HyperLink1
, I am not.
How can you pass in multiple objects into the page? I have tried importing both namespaces without success - i.e.
<%@ Import Namespace="Tolling.Models.News" %>
<%@ Import Namespace="Tolling.Models.HyperLinks" %>
You can pass extra data into the View by using ViewData, TempData, Session or Cache. I'd suggest you use ViewData. As described by MSDN: