MVC View Model Intellisense / Compile error
Posted
by Marty Trenouth
on Stack Overflow
See other posts from Stack Overflow
or by Marty Trenouth
Published on 2010-04-21T18:48:22Z
Indexed on
2010/04/22
9:03 UTC
Read the original article
Hit count: 445
c#
|asp.net-mvc
I have one Library with my ORM and am working with a MVC Application. I have a problem where the pages won't compile because the Views can't see the Model's properties (which are inherited from lower level base classes). They system throws a compile error saying that
'object' does not contain a definition for 'ID' and no extension method 'ID' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
implying that the View is not seeing the model. In the Controller I have full access to the Model and have check the Inherits from portion of the view to validate the correct type is being passed.
Controller:
return View(new TeraViral_Blog());
View:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<com.models.TeraViral_Blog>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Index2
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Index2</h2>
<fieldset>
<legend>Fields</legend>
<p>
ID:
<%= Html.Encode(Model.ID) %>
</p>
</fieldset>
</asp:Content>
© Stack Overflow or respective owner