In DinnerController
I got a data.
public ActionResult Details(int id)
{
Dinner dinner = dinnerRepository.GetDinner(id);
if (dinner == null)
return View("NotFound");
else
return View("Details", dinner);
}
and in details.aspx
I bound it like this.
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>
Details</h2>
<fieldset>
<legend>Fields</legend>
<p>
DinnerID:
<%= Html.Encode(Model.DinnerID) %>
</p>
</fieldset>
</asp:Content>
but I got a error.
Compiler Error Message: CS1061: 'object' does not contain a definition for 'DinnerID' and no extension method 'DinnerID' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
.
I just start to learn mvc
and unable to understand the problem.May I missing something.Plz help?
I forget to check the check box Create a strongly-typed view
when create a view show i got this error.i solve this through adding <HelloMvc.Models.Dinner>
in details.aspx
page.
Means when I got error code like this.
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage" %>
After solve the problem code becames:
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<HelloMvc.Models.Dinner>" %>
Thanks for reply.I post this ans for future ref.